Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how do i make player lose a stat on leave?

i have made this script so when the player leaves their PetM Value will = 0 but it is not working. can somebody help?

if game.Players.PlayerRemoving:Connect(function(player)
	player.PlayerStats.PetM.Value = player.PlayerStats.PetM.Value == 0
end)

1 answer

✓ Accepted answer

player.PlayerStats.PetM.Value == 0 is a boolean expression, not an integer or number. Your script should look like this:

game.Players.PlayerRemoving:Connect(function(player)
    player.PlayerStats.PetM.Value = 0 -- Assign 0 to PetM instead of whether or not it is equal to 0
end

Note: This note is not related to your question, but your desire to change a player's stat before they leave the game perplexes me, as doing so will probably have no effect on gameplay unless something happens when PetM is set to 0.

This discussion is preserved as it was. New answers, comments, and votes are closed.