I have noticed that after a player dies, the local script belonging to the player no longer functions. For example:
Player.PlayerGui.ScreenGui.Button.MouseButton1Click:connect(function()
print("button clicked")
end)
The script would function as normal, but I wondered what would happen if the player dies. However, upon respawning, the button no longer prints suggesting the button is not being clicked. The script is located in StarterPlayerScripts.
I like to believe that the reason behind this is because the script is still attached to the previous PlayerGui and since the player has died, the previous PlayerGui has been replaced with a new one. May someone clarify this and how people resolve this problem?

5 comments
um put it inside the Button gui object
local scripts in player gui will always refresh on death
I remember it from a while ago, I don't know if it changed or not
Did you check if the ScreenGui resets on spawn?
i agree with greatneil80 when Player dies PlayerGui always resets but also remember if ResetOnSpawn is disabled then it will not reset the Gui