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

How do I give ALL players a hat?

Asked by 10 years ago

I need to know how to give ALL players a hat, not just one players.

2 answers

Log in to vote
0
Answered by
MixCorp 70
10 years ago

If you want to just add it to the Players other Hats:

AHat = nil --Put the hat you need in here.
for i,v in pairs(game.Players:children()) do
if v.Character then
Hat = AHat:clone()
Hat.Parent = v.Character
end
end

To remove the players hats then give new hat:

AHat = nil --Put hat you need here
for i,v in pairs(game.Players:children()) do
if v.Character then
for i,Noob in pairs(v.Character:children()) do
if Noob.className == "Hat" then
Noob:remove()
end
end
AHat:clone().Parent = v.Character
end
end

Ad
Log in to vote
0
Answered by 10 years ago

These did not work out for me. Try using this instead:

NewHatString = game.Lighting.TheHatYouWant --Put the string of the hat in here.

game.Workspace.DescendantAdded:connect(function(TheHat)
    if TheHat:IsA("Hat") then
        local NewHat = NewHatString:Clone()
        NewHat.Parent = TheHat.Parent
        NewHat.Name = NewHatString.Name
        TheHat:Destroy()
    end
end)

Hope it works.

Answer this question