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)

4 comments
Is it in script or local script?
It's better to handle these kinda matters locally rather than script.
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?
Ended up converting it to a LocalScript and did some other fidgeting and got it to work.