Okay so I have a working menu, and I disabled character auto loads so that you can click play and it will spawn in your character, but whenever the character dies, I don't know how to "unload" it and make it go back to the title screen. If I use :Destroy() on the character, all of the gui's that I already have will all have errors that say there is no character to localplayer.
COMMUNITY QUESTION
How do I "unload" a character?
1 answer
Quick Answer
You can use :LoadCharacter
Code to simulate re-spawning
local respawnDelay = 5
game.Players.CharacterAutoLoads = false
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
-- find the humanoid, and detect when it dies
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
humanoid.Died:Connect(function()
wait(respawnDelay)
player:LoadCharacter()
end)
end
end)
player:LoadCharacter() -- load the character for the first time
end)
Explanation
The purpose of the code above is to manually re spawn characters instead of using AutoLoadCharacter. When the humanoid's health reaches 0 (player dies) this code will detect it and load the character after the chosen re spawn delay.
Sources
2 comments
0
I already know how to load a character, but how do I remove the character
0
You need to use :Destroy() on the server side. Use a remote event when the char dies and have the server script :Destroy() the character.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
put ur script in a CharacterAdded function