ROBLOX:生命值降到零后输出信息没有弹出

我正在尝试在 Roblox 中创建某种积分系统。我希望在杀死 Humanoid 后将 150 分加到我的分数上,但是我的脚本什么也没有做。有什么指针吗?我是新手。

查看我的代码这里,或者只需在下面阅读:

local function score(points)
    score = 0
    local points = score + 150
    if game.Workspace.Dummy.Humanoid.Health == 0 then
        print("good")
    end
end
点赞
用户7659637
用户7659637

尝试使用Signal Died()

http://wiki.roblox.com/index.php?title=API:Class/Humanoid/Died

描述:在角色的健康值达到0后触发。可以通过将头从躯干中断开或直接设置health属性来引起此情况。

这应该为你提供了一个事件,当你的Humanoid死亡时触发。

像这样:

game.Workspace.Dummy.Humanoid.Died:connect(function()
    print("good")
end)
2017-03-06 01:34:04