I am trying to make an AI enemy respawn when the player dies, the script that Ihave isn't working, I get no errors.
plr = game.Players.LocalPlayer
char = plr.Character
z = script.Parent
backup = z:clone()
while true do
wait(5)
if char.Humanoid.Health == 0 then
print("ded")
z:Remove()
wait(2)
backup.Parent = game.Workspace
backup.Head:MakeJoints()
backup.Torso:MakeJoints()
if z == nil then
wait(4)
backup.Parent = game.Workspace
backup.Head:MakeJoints()
backup.Torso:MakeJoints()
end
end
end

1 comment
Perhaps it would be helpful if you were to explain what exactly is happening and how its not working. Though if I were to give a recommendation, you should do Humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false) to prevent the joints from breaking automatically, and renable it to true once you've restored it's health.