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

My code isn't working?

game.Players.PlayerAdded:connect(function(Plr)
    Plr.CharacterAdded:connect(function(Char)
        local Contents = Char:GetChildren()
        for _, v in pairs(Contents) -- Remove all existing hats to add new one(s)
            if v:IsA("Hat") then
                v:remove()
            end
        end
        if Plr.TeamColor == BrickColor.new("Really blue") then -- Check the team Color
            local Hat1 = game.ServerStorage:Clone()
            Hat1.Parent = Char
        elseif Plr.TeamColor == BrickColor.new("Really red") then
            local Hat2 = game.ServerStorage:Clone()
            Hat2.Parent = Char
        end
    end)
end)

(It's supposed to give players a different hat when they're on a certain team, but I can't get it to work.)

1 answer

local Hat1 = game.ServerStorage:Clone()


You're cloning ServerStorage and not a hat.

5 comments

0

So I would fix this by saying: local Hat1 = game.ServerStorage.Hat1:Clone()? Would that work?

0

Yes

0

Still not working :/

0

local Hat2 = game.ServerStorage:Clone()-- that one too

0

I did.....

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