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 4 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?

function remove()
local p = game.Players.LocalPlayer
local c = p.Character
       wait(1)
       for i,v in pairs(c:GetChildren()) do
           if v:IsA("Accessory") then
              v:remove()
        end
    end
end

script.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 4 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"

function remove()
    local p = game.Players.LocalPlayer
    local c = p.Character
    wait(1)
    for i,v in pairs(c:GetChildren()) do
            if v:IsA("Accessory") then
            for e, r in pairs(v.Handle:GetChildren()) do --goes through all the items in the handle to find the attachment
                if r:IsA("Attachment") then --locates the attachment
                    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
                        v:Destroy()
                    end
                end
            end
            end
    end
end

script.Parent.MouseButton1Down:Connect(remove)
0
This works fantastically, thank you very much! flamethower2002 50 — 4y
0
If you need help to find the name of the attachment for other hat types to remove, just ask XxOPGUYxX1234567 221 — 4y
Ad

Answer this question