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

How would I go about removing a certain type of accessory?

Asked by 5 years ago

I only want to remove certain accessory types, such as hairs, and hats, leaving glasses, waist and shoulder accessories. What could I add to the script, so it will only target the type of accessory I want to remove?

01function remove()
02local p = game.Players.LocalPlayer
03local c = p.Character
04       wait(1)
05       for i,v in pairs(c:GetChildren()) do
06           if v:IsA("Accessory") then
07              v:remove()
08        end
09    end
10end
11 
12script.Parent.MouseButton1Down:connect(remove)

I assume I'd have to find the attachment part of the accessory, and target only that. But I'm not sure how I could seek out the attachments for each and every accessory part on ROBLOX.

The script is a local script inside of a ScreenGUI.

1 answer

Log in to vote
3
Answered by 5 years ago

theres probably a much simpler way to do this but here we go.

To check the type of accessory, a way I found is to go under the accessory and in there is a handle and inside of that is an attachment. The name of the attachment is key to this. For example, a hair attachment would be called "HairAttachment"

01function remove()
02    local p = game.Players.LocalPlayer
03    local c = p.Character
04    wait(1)
05    for i,v in pairs(c:GetChildren()) do
06            if v:IsA("Accessory") then
07            for e, r in pairs(v.Handle:GetChildren()) do --goes through all the items in the handle to find the attachment
08                if r:IsA("Attachment") then --locates the attachment
09                    if r.Name == "HatAttachment" or r.Name == "HairAttachment" then --Here you would find the name of the attachment from the specific accessory type and add it to the list. I made it so it removes hats and hairs
10                        v:Destroy()
11                    end
12                end
13            end
14            end
15    end
16end
17 
18script.Parent.MouseButton1Down:Connect(remove)
0
This works fantastically, thank you very much! flamethower2002 50 — 5y
0
If you need help to find the name of the attachment for other hat types to remove, just ask XxOPGUYxX1234567 221 — 5y
Ad

Answer this question