Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Enum.HumanoidStateType.Dead not working on server?

Asked by
Rhidlor 42
6 years ago

So I have the code in a Script in StarterCharacterScripts and it works locally but not on a server. I figured I'd ask here because its probably something small I overlooked, so if anyone could point out my problem it would be greatly appreciated!

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local dead = script.Dead

humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
local deathAnimation = humanoid:LoadAnimation(script.Death)

humanoid.HealthChanged:Connect(function()
    if humanoid.Health <= 0 and dead.Value ~= true then
        humanoid.Health = 0
        dead.Value = true
        deathAnimation:Play()
        wait(0.5)
        humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, true)
    end
end)
0
Is it in script or local script? PlaasBoer 275 — 6y
0
It's better to handle these kinda matters locally rather than script. mynamajeff1302 2 — 6y
0
If I were to handle this locally it would require a number of events no? I don't fully understand the implications of LocalScripts but it wouldn't be possible to manipulate the properties of a humanoid without events would it? Rhidlor 42 — 6y
0
Ended up converting it to a LocalScript and did some other fidgeting and got it to work. Rhidlor 42 — 6y

Answer this question