Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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!

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 Vividex 162 — 10y
1
Yes, you can get the name from the PlayerAdded Event. Shawnyg 4330 — 10y
0
Oops sorry, my bad. Vividex 162 — 10y

1 answer

Log in to vote
5
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

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)


0
Thanks! iRzPWNzr 20 — 10y
0
No problem! Glad I could help. Shawnyg 4330 — 10y
Ad

Answer this question