I am still really new at this game and have never done any scripting before, so I have no idea if there is a better way to do this or what.
I am trying to make it so that when a specific player joins they spawn with some hats I added to a model inside ServerStorage. It works perfectly fine in studio, but gives me an error in online mode.
This is the error I get in the console in online mode: ServerScriptService.OnlinePlayerHat: 1: attempt to index a nil value Stack Begin Script 'ServerScriptService.OnlinePlayerHat', Line 1 Stack End
This is the script: (Yes, I switch "Player" with my username before I play it in online)
repeat wait() until game.Players:findFirstChild("Player").Character
GiveHats = true
Char = game.Players:findFirstChild("Player").Character
wait()
if GiveHats then
for index, child in pairs(game.ServerStorage.Hats:GetChildren()) do
child:Clone().Parent = Char
end
end
I also uncopylocked my place if you want to look at it and get a better understanding of what I am trying to do since you can see it work in studio mode. http://www.roblox.com/games/201535173/FluxBloxs-Place
It would be nice if someone could either fix this, or give me a simpler script that actually works the same as what this does in studio mode.
(Sorry if anyone saw this already, I deleted the original post I had of it so I could try to get it working again, but still keep getting the same issue)

2 comments
Already tried that, it still only worked in studio.
Chang e it to wait(.5) that should work