I am making my game handle a players death properly. Before, I had everything stored in PlayerScripts, which meant the character would break permanently if the player died. Now, I’ve modified the code to go in CharacterScripts, so it will reset on death.
I am not disconnecting any events when this happens, and on respawn, certain aspects of the new character script are acting unusually. ( Event related code. )
Do I need to be disconnecting these when the player dies? Will these events stack? Or get cleaned up when the model is reloaded.
I am using LoadCharacter to respawn the player on Humanoid:Died() if that makes a difference.
For some reason when you respawn and such the character is not destroyed, but just parented to nil.
What I do to guarantee disconnections is
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.CharacterRemoving:Connect(game.Destroy)
end)
So that when their character is being removed it will be destroyed rather than just parented to nil. This might be redundant but it is good to guarantee things.