Local script is breaks!

Hi developers!

The local script breaks when the player dies. Is there a way to make the script not be deleted on death?
I will say right away - I need to insert the script into the player from the server.

I’ve been trying to fix it for about 3 hours…:smiling_face_with_tear: I’ve tried - pasting into a character, pasting into the GUI…

1 Like

Is there any specific reason on parenting the script from server to player. What are you trying to achieve

1 Like

I’m making a map for some game, and for optimization I use local scripts that control models, creatures, etc. As the player dies, local scripts disappear, local objects break.

Put the script inside of StarterCharacterScripts this will ensure that the script will be added when the character is added to the game again

thus running like nothing ever happened

Is this script being cloned into the player’s character that you’re trying to achieve? I’d say there’s no way of not having it be deleted on death since, when the player fully dies and then respawns, the player’s character will be recreated into its original state.

What you could do, though, is put the script in StarterCharacterScripts OR connect a Player.CharacterAdded event to the server script that’s cloning the local script to clone the local script whenever the character is being added. (respawned)

1 Like

It’s sad, but this seems to be the only solution to the problem … But thanks anyway for the help and long text)

1 Like

Seems like you didn’t put your script in it’s belonged folder, it’s called StarterCharacterScripts or StarterPlayerScripts, both of these are located in StarterPlayer Folder.

Or your script runs before the Character even loads, do this instead:

local Character = YourPlayerVariable.Character or YourPlayerVariable.CharacterAdded:Wait()

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.