首页 > 解决方案 > humanoid.health 始终为 100,但实际上不是 100

问题描述

所以我试图制作一个roblox游戏,我试图检测npc的健康何时为0它会停止射击,但它总是在100,请帮助

me = script.Parent.Parent.Parent.Parent:FindFirstChild("Humanoid")
function touched(hit)
    if me.Health > 0 then
        if hit.Parent:FindFirstChild("Humanoid") ~= nil then
            script.Parent.Parent.shoot.Shotgun:Play()
            script.Parent.Parent.shoot.Transparency = 0;
            script.Parent.Parent.shoot.CanTouch = true;
            wait(0.2)
            script.Parent.Parent.shoot.Transparency = 1;
            script.Parent.Parent.shoot.CanTouch = false;
            wait(0.05)
            script.Parent.Position += Vector3.new(0,200,0)
            wait(0)
            script.Parent.Position -= Vector3.new(0,200,0)
        end
    end
end

script.Parent.Touched:Connect(touched)

标签: luaroblox

解决方案


推荐阅读