如何在杀死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 --将Money更改为增加的统计数据。
                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)
点赞
用户12968803
用户12968803

不确定,但是看起来是

score.Value = Leaderstats.Score.Value
2021-08-02 07:22:34