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?
01 | function 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 | v:remove() |
08 | end |
09 | end |
10 | end |
11 |
12 | script.Parent.MouseButton 1 Down: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.
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"
01 | function 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 |
16 | end |
17 |
18 | script.Parent.MouseButton 1 Down:Connect(remove) |