I have this script that is a Kill Spree leaderstat and resets when you die (It works once), but if you die a second time your Spree value doesn’t reset to 0?
Script:
game.Players.PlayerAdded:Connect(function(player)
local rs = game:GetService(“ReplicatedStorage”)
local char = player.Character or player.CharacterAdded:wait()
local human = char:WaitForChild(“Humanoid”)
local spreestat = player:WaitForChild(“leaderstats”)
OHHHH, i figured it out… since you put the human.died function inside the player added it only will fire and check when a player is added
try adding a while true do @Aozwel
Please please PLEASE do not use a loop in your script. This is the most unnecessary thing. @Jacko_Korbius@WhatDid_HeDo I advised that you carefully understand the purpose of looping. There are better methods than looping.
@OP, the reason it doesn’t reset the 2nd time you die is because PlayerAdded only fires once. When you reset, the character is deleted and you will get a new character. Since you only added the event once, which is after PlayerAdded, the new character doesn’t get the event.
The solution is to add a CharacterAdded. This fires when the Player has a character in the Workspace.
Try using this post as it seems someone’s already posted about this. This post also explains how to implement Character Added. Resetting leaderboard timer after death, there are some other replies besides the one linked that should help.
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local rs = game:GetService(“ReplicatedStorage”)
local human = char:WaitForChild(“Humanoid”)
local spreestat = player:WaitForChild(“leaderstats”)
– Reset spree
human.Died:Connect(function()
spreestat.Spree.Value = 0
end)
end
end)