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

How to remove player's hats and equip them with a new one?

Trying to make a script where when a player joins and is on a certain team, the hats they are currently wearing are removed THEN replaced with a new hat. This is what I have so far, I don't know how to insert a hat from the ROBLOX catalog and weld it onto the player's head

local teams = {"British Army"}

function isTeam(plr)
for _,v in pairs(teams) do
if game.Teams[v].TeamColor == plr.TeamColor then
return true
end
end
return false
end

game.Players.PlayerAdded:connect(function(np)
    np.CharacterAdded:connect(function(nc)
        if isTeam(np) then
            nc.ChildAdded:connect(function(item)
                if item:IsA("Accessory") then
                    item:Destroy()
                end
            end)
        end
    end)
end)

Thank you

1 comment

0

To remove hat: for i,v, in pairs(np:GetChildren()) do if v:IsA("Accessory") do v:Remove() end end

1 answer

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