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

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

Asked by 6 years ago

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

0
To remove hat: for i,v, in pairs(np:GetChildren()) do if v:IsA("Accessory") do v:Remove() end end Nikkulaos 229 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

First of all, Make it so the characters appearance doesn't load for this game. If you want you can use this script, its pretty self explanatory once you insert it into your game.

Just Remember to make the characters appearance not load for the British Army

https://www.roblox.com/library/150709829/Give-all-players-clothing-on-spawn

Ad

Answer this question