Hats goes away after death

I have a module script and a server script that put items that a player gets from ingame on the player when they join but when the player dies the hats go away and do not come back unless if the player re equips it or rejoins. Is there a way to make the hats stay on or auto re equip itself when the player dies? Heres the scripts image image

1 Like

First thing’s first, refrain from using spawn, instead, use coroutine. Read this post that explains exactly why. But in short, it has a built-in wait function that can get very crazy especially when you use it excessively. But even once, you shouldn’t take that risk. Think of it as being deprecated.

Second, you can just do player.Character instead of searching the workspace for with their name.

Now onto the actual script:
You’re only running the for loop once at the end. You need to connect a function to an even that detects when the player’s character spawns (or respawns) in.

player.CharacterAdded:Connect(function()

    characterAdded(player)

end)

Putting that inside of the loop should work.

Hope that helps!

1 Like

Thanks man this worked and ill make sure to use coroutine instead of spawn.