Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Give a player a hat in ServerStorage every time they spawn? [Solved!]

Hello, I'm kinda new to Lua, so if you could be specific as possible, that would be great.

I'm trying to make a script where every time a player spawns, they get a hat, which I've put in ServerStorage. (And yes, the hat works)

Here's what I've tried:

game.Players.PlayerAdded:connect(function(ply)
ply.CharacterAdded:connect(function(char)
if ply.Name=="iRzPWNzr" or "Player1" then --Player1 is in there for Studio testing
game.ServerStorage.DevDominus:Clone().Parent = ply.char
end end) end)

Any help is appreciated. Thank you!

3 comments

0

I'm not sure you can get the name with a PlayerAdded connect function, I would you for i,v in pairs (game.Workspace:GetChildren()) do if v.Name == "Player1" then

1

Yes, you can get the name from the PlayerAdded Event.

0

Oops sorry, my bad.

1 answer

✓ Accepted answer

You messed up on Line 3 and 4.

game.Players.PlayerAdded:connect(function(ply)
	ply.CharacterAdded:connect(function(char)
	if ply.Name=="iRzPWNzr" or ply.Name == "Player1" then --Player1 is in there for Studio testing
		game.ServerStorage.DevDominus:Clone().Parent = char
	end
end)
end)


2 comments

0

Thanks!

0

No problem! Glad I could help.

This discussion is preserved as it was. New answers, comments, and votes are closed.