LocalScript Disabled when player respawns

I’ve searched the web try to find a viable way to “fix” this issue. No luck. For some odd reason, my local script (controls majority of the client) gets disabled when the player dies or respawns. How would I “restart” or “re-enabled” the local script when the player respawns? Loading into the game for the first time works nearly perfect.

Code Example:

print("Start")
do
  local player = game.Players.LocalPlayer
  function printPlayerName()
     print(player.Name)
  end

  printPlayerName() -- Only runs once (doesn't run after player respawns)
end

Appreciate responses.

1 Like

This is probably some issue with the code so it would be useful to have some sort code snippet if possible!

My best guess is that your script doesn’t account for the player’s character being re-added and hence only runs when the script begins.

However it could be a number of scenarios that cause this issue so some code and maybe more detail of where the localscript is located would be nice.

If your script is in startergui then make sure that it is parented to a ScreenGui that has ScreenGui.ResetOnSpawn set to false.

Unfortunatley, unless you provide code samples, it’s very hard to help.
I assume you have a LocalScript inside a StarterGui, so maybe the StarterGui.ResetOnSpawn property is set to true?

PlayerScripts not StarterGui .

print("Start")
do
    print("hi") -- Doesn't run when the player respawns
end

Ok so how is this supposed to help? You’ve just posed a block of code with no context or anyway of how it could possibly be fixed

LocalScripts parented to StarterPlayer scripts dont just disable themself

Updated the OP with a code example. Thanks.

I updated the OP with a better example.

put it in startercharacterscripts

i cant anymore help me

2 Likes