This script is inside a NPC, that has a humanoid called Enemy. The problem is when he dies he just dies. My script is supposed to make him play an Animation, but it doesn't work. It only works in roblox studio, but not in game.
local dead = false
script.Parent.Enemy.Changed:connect(function()
if script.Parent.Enemy.Health <= 0 and dead == false then
script.Parent.Enemy.Health = 100
dead = true
script.Parent.Enemy.WalkSpeed = 0
script.Parent.Attack.Disabled = true -- other script
script.Parent.Damager.Disabled = true -- other script
script.Parent.Follow.Disabled = true -- other script
local Ded = script.Parent.Enemy:LoadAnimation(script.Parent.Die)
Ded:Play()
wait(2)
script.Parent.Enemy.Health = 0
end
end)
