I have a script set up to make the leaderstat "Streak" go up by one every time you hit a checkpoint. What can I do to make it so that whenever a player dies, it goes back down to 0? I've tried a function, but it isn't working.
function ot(hit)
if hit.Parent ~= nil then
player = game.Players:playerFromCharacter(hit.Parent)
if player ~= nil then
if player.leaderstats.Stage.Value == script.Parent.Name - 1 then
h = hit.Parent:FindFirstChild("Humanoid")
if h ~= nil then
if h.Health ~= 0 then
player.leaderstats.Stage.Value = script.Parent.Name
player.leaderstats.Streak.Value = player.leaderstats.Streak.Value + 1
end end end end end end
function died()
player.leaderstats.Streak.Value = 0
end
script.Parent.Touched:connect(ot)
h.Died:connect(died)

3 comments
Like this? h.Died:connect(function() player.leaderstats.Streak.Value = 0 end)
Because that seems to be wrong.
Like it isn't working at all?