#How to make an hat/accessories remover part with Click?

1 messages · Page 1 of 1 (latest)

devout breach
#

So I am trying to inform myself how to script an hat remover part for about 2 hours cuz I have minimal knowledge of Scripting….
(I am an builder thats why)
If there someone that can as well give me information how to make an hat giver that would be very helpful.

slate pasture
#

make a anchored part, add a clickdetector to it and keep it named the same way, then add a script inside and add this code:

local click = script.Parent.ClickDetector

click.MouseClick:Connect(function(plr:Player)
    local character = plr.Character
    for _, accessory:Accessory in character:GetChildren() do
        if accessory:IsA("Accessory") then
            if accessory.AccessoryType == Enum.AccessoryType.Hat then
                accessory:Destroy()
            end
        end
    end
end)

this code will destroy all hat accessories of players that click on the clickdetector

if you want, i can make another version that destorys hair too or destroys all accessory regardless of accessory type