lua - 杀死NPC时如何得分
问题描述
当我杀死一个NPC时,我的分数应该会增加,但不会。
这是我的代码。它位于我的 NPC 模型下。
local Humanoid = script.Parent.Humanoid
function PwntX_X()
local tag = Humanoid:findFirstChild("creator")
if tag ~= nil then
if tag.Value ~= nil then
local Leaderstats = tag.Value:findFirstChild("leaderstats")
if Leaderstats ~= nil then
Leaderstats.Score.Value = Leaderstats.Score.Value + 250 --Change Money to the stat that is increased.
wait(0.1)
script:remove()
end
end
end
end
Humanoid.Died:connect(PwntX_X)
这是我的排行榜代码
game.Players.PlayerAdded:Connect(function(plr)
local stats = Instance.new("BoolValue",plr)
stats.Name = "leaderstats"
local score = Instance.new("IntValue", stats)
score.Name = "Score"
score.Value = 0
end)
解决方案
不确定,但看起来像
score.Value = Leaderstats.Score.Value
推荐阅读
- java - 如何使用@Qualifier 来识别应该使用的bean
- android - 使用 Retrofit 的动态数据的可扩展列表视图
- reactjs - 用于 React Native 的 NATS.io?
- sequelize.js - 如果日期过滤器为空或“”,则返回所有行
- neo4j - 在 gremlin 中相当于重复和直到的密码
- github - 来自 fork 的标签显示在主存储库中
- mule - Mulesoft_ 无法向多个电子邮件地址发送电子邮件
- python - 如何结束另一个线程中的while循环?
- wpf - 键入值时如何在 ComboBox.Text 上实现 IDataErrorInfo?
- swift - 当标签中的文本大于屏幕时,滚动视图不滚动