I have a short script here, it's meant to reset the "Spree" leaderstat of a player to 0 when it dies. It doesn't reset.
PPS = game:GetService("PointsService") game.Players.PlayerAdded:connect(function(player) counter = Instance.new("NumberValue",player) counter.Name = "Counter" counter.Changed:connect(function(item) if counter.Value >= 10 then counter.Value = 0 player.leaderstats.FPoints.Value = player.leaderstats.FPoints.Value +1 PPS:AwardPoints(player.userId,1) end end) while wait() do if player.Character ~= nil then break end end player.Character.Humanoid.Died:connect(function() counter.Value = 0 player.leaderstats.Spree.Value = 0 end) end)
You are only getting the first character. Once the character dies and another character is created, it doesn't care about the new one. Connect to the character with player.CharacterAdded
local PPS=game:GetService("PointsService") game.Players.PlayerAdded:connect(function(player) local counter=Instance.new("NumberValue",player) counter.Name="Counter" counter.Changed:connect(function(item) if counter.Value>=10 then counter.Value=0 player.leaderstats.FPoints.Value=player.leaderstats.FPoints.Value+1 PPS:AwardPoints(player.UserId,1) end end) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() counter.Value=0 player.leaderstats.Spree.Value=0 end) end) end)
It also seems that you're using leaderstats
and its elements but not creating them in this PlayerAdded
connection. I recommend only using one connection to PlayerAdded.