I am making a platformer game and I want to make the level reset every time the player dies but I am not sure how to go about it, any information is welcome!
COMMUNITY QUESTION
Level Reset on Player Death?
3 answers
To answer your question a way you can go about this is make something to watch for the players death and then run code that will reset everything once they die to the point you want to.
Insert a checkpoint in the first level, so everytime they lose they spawn there, DONT add any other checkpoints
not a request site, but you can add a script inside of StarterCharacterScript and use a loop to check for player's health. And when the health is 0 then you get the player's level and set it to 0.
maybe something like this:
local hum = script.Parent:WaitForChild("Humanoid")
while wait() do
if hum.Health <= 0 then
local player = game.Players:GetPlayerFromCharacter(script.Parent)
player:WaitForChild("leaderstats").level.Value = 0
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
there is a
Humanoid.DiedeventUse the Died event of the Humanoid to Connect a listener to this. Applying a loop is inefficient