Hi I have a script where if you touch the part you will become transparent for 5 seconds and reappear again, but for some reason accessories won't become transparent with the rest.
01 | function setTransparency(char, value) |
02 | for _, child in pairs (char:GetChildren()) do |
03 | if child:IsA( 'Accessory' ) and child:FindFirstChild( "Handle" ) then |
04 | child = child.Handle |
05 | elseif child:IsA( 'BasePart' ) and child.name ~ = "HumanoidRootPart" then |
06 | child.Transparency = value |
07 | end |
08 | end |
09 | end |
10 |
11 | local enabled = true |
12 | game.Workspace.TransPart.Touched:connect( function (hit) |
13 | local char = hit.Parent |
14 | if char then |
15 | local head = char:FindFirstChild( "Head" ) |
I might have the solution to your problem:
1 | if child:IsA( "Accessory" ) then |
2 | for _, accessoryPart in pairs (child:GetChildren()) do |
3 | if accessoryPart.ClassName = = "Part" then |
4 | accessoryPart.Transparency = value -- or whatever you define your transparency as |
5 | end |
So basically, all accessories have a child called "handle" that makes the accessory's shape. So what we are doing is finding the children of the accessory and if they are a part, we are setting its transparency to 1, thus making it invisible. This is since all instances with the class name of "Part" have the transparency property. (The handle is a part.)
Try this and if it doesn't work or you need a better explanation of how it works, tell me in the comments. If this is the answer please consider marking this as the answer, so we both can get reputation points :D. I hope you have a great day!