so i have a leaderstat in my game called "Lives" but i dont know how to lower it by 1 whenever the player dies, i dont know where to start so i made this script which is probably not even close. also the amount of lives the player starts with is 25 if it helps.
local player = game.Players.LocalPlayer local lives = player.leaderstats.Lives if player.Humanoid.Health = 0 then lives.Value = lives.Value - 1 end
thanks
You can use the Died event that fires everytime the humanoid dies.
(This should be a normal script in ServerScriptService)
game.Players.ChildAdded:Connect(function(player) player.CharacterAdded:Connect(function(char) local hum = char:FindFirstChildOfClass('Humanoid') hum.Died:Connect(function() local lives = player:WaitForChild('leaderstats'):WaitForChild('Lives') lives.Value = lives.Value - 1 end) end) end)
Should be done in a normal script, because changing the lives on the client will not replicate to the server