I have this script which activates on Death:
local Player=script.Parent.Parent
repeat wait() until Player.Character
local Character=Player.Character
local Humanoid=Character:WaitForChild("Humanoid")
local Stats=Player:WaitForChild("leaderstats")
local Respawns=Stats:WaitForChild("Respawns")
function Search(Obj)
for i,v in pairs(Obj:GetChildren()) do
if v.ClassName=="Sound" then
v:Stop()
end
Search(v)
end
end
function Death()
if Humanoid.Health<=0 then
if Respawns.Value>0 then
Respawns.Value=Respawns.Value-1
Search(Player)
wait()
Player.Backpack.Death:Play()
end
end
end
Humanoid.Changed:connect(Death)
It sometimes fires multiple times when you die however and takes too many lives away from your stats. How can I fix this?
