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

How do I make Accessory transparent? [R15]

Asked by 4 years ago
Edited 4 years ago

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.

01function 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
09end
10 
11local enabled = true
12game.Workspace.TransPart.Touched:connect(function(hit)
13    local char = hit.Parent
14    if char then
15        local head = char:FindFirstChild("Head")
View all 34 lines...

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

I might have the solution to your problem:

1if 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
5end

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!

0
Thank you so much for the answer! habloshom 9 — 4y
0
No problem :) SprinkledFruit101 135 — 4y
Ad

Answer this question