Okay, I made this script so when the player's health is 0, then it clones the script called deathscript to the character. Sadly the results didn't come according to plan. I tried rewriting it many times. I'm a beginner scriptwriter, and I would appreciate if you help me and tell me the problem.
local player = game.Players.LocalPlayer.Character local humanoid = player.Humanoid while wait() do local dead = script.deathscript:Clone() if humanoid.Health <= 0 then dead.Parent = player end end
You should use the .Died event that the humanoid object has. It will trigger when the humanoid/player dies(i.e health is 0 or <):
local player = game.Players.LocalPlayer.Character local humanoid = player.Humanoid while wait() do local dead = script.deathscript:Clone() humanoid.Died:connect(function() dead.Parent = player; end) end