【问题标题】:How to score when killing an NPC杀死NPC时如何得分
【发布时间】:2021-10-07 12:15:45
【问题描述】:

当我杀死一个 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)

【问题讨论】:

  • 看起来保存到“Creator”对象的任何值都用于定位杀死NPC的玩家。您的任何工具或枪支是否会修改此值?另外,当您测试此代码时,“输出”窗口中是否有任何错误。
  • 我对@9​​87654323@ 一无所知,但local Leaderstats = tag.Value:findFirstChild("leaderstats") 不应该类似于local score = tag.Value:findFirstChild("Score"),因为它是您要更改的IntValue 分数,而不是BoolValue leaderstats。跨度>
  • @KenY-N,他们正在使用Leaderstats.Score.Value 将Score 编入索引

标签: lua roblox


【解决方案1】:

不确定,但看起来像

score.Value = Leaderstats.Score.Value

【讨论】:

    猜你喜欢
    • 2019-05-19
    • 2013-11-12
    • 2012-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多