01 | player = game.Players.LocalPlayer |
02 | character = player.Character |
03 | HatClone = game.ReplicatedStorage.GokuHair:Clone() |
04 |
05 | function clone() |
06 | game.ReplicatedStorage.GokuHair:Clone() |
07 | HatClone.Parent = character |
08 | end |
09 |
10 | game.Players.PlayerAdded:Connect(clone) |
I think the problem here is that you are calling the function when the PLAYER has been added, when the player gets added it takes a small amount of time before your character spawns in. I would suggest you try to use .CharacterAdded and see if that works.
Be sure your script is located inside of the Workspace or the ServerScriptService and be sure it's not a localscript! Your script was not working because you didn't wait for the Player's character to spawn. Also, you should clone the hat inside of the function.
New Script:
1 | function clone(Player) |
2 | local HatClone = game.ReplicatedStorage.GokuHair:Clone() |
3 | Player.CharacterAdded:Connect( function (Char) |
4 | HatClone.Parent = Char |
5 | end ) |
6 | end |
7 |
8 | game.Players.PlayerAdded:Connect(clone) |