How to completely restart the game for a player when he resets its character?

When a player joins my game, he gets a lot of PlayerAdded processing from Server and LocalScript before starting.
But when this player resets its character, the game doesn’t restart normally.
image

How do I force the game to start from scratch for this player when he resets the character, ie as if he has left and rejoined the game (will go through Server/PlayerAdded, then Local/Playeradded normally)?

2 Likes

Since no one answers, I’ll make the question easier:

How to intercept the Reset Character button, how to run a function after the player resets the character?

Can you explain in more detail what you mean by this. Have you got code executing causing this issues?

That’s not the point. The problem is that Reset Button doesn’t restart the game, it just reset the character.
So I’d like to know how to intercept the Reset Button click so I could run my own code for that.

I got the solution:

This will intercept the Reset Character button:

local resetBindable = Instance.new("BindableEvent")
resetBindable.Event:connect(function()
	print('reset')
end)

-- This will remove the current behavior for when the reset button 
-- is pressed and just fire resetBindable instead.
game:GetService("StarterGui"):SetCore("ResetButtonCallback", resetBindable)

… and also, if I want to disable the Reset Character button:

-- Setting ResetButtonCallback to false will grey out the reset button
-- in the menu and players won't be able to reset in your game.
game:GetService("StarterGui"):SetCore("ResetButtonCallback", false)
2 Likes

Im still a bit lost as to what you need if the players character dies you can just listern for that event. You are also able to control when the players caracters spawns in.