I have a script that finds a folder that contains a model of a grappling hook. It's supposed to only change the transparency of descendants whose name are "Union" "a" or "b".
local descendants = game.Workspace.grapples.grapple:GetDescendants() for index, descendant in pairs(descendants) do if descendant:IsA("BasePart") or descendant.Name == "Union" or descendant.Name == "a" or descendant.Name == "b" then descendant.BrickColor = BrickColor.new("Really red") descendant.Transparency = 0 end end
Obviously the script doesn't work because I'm not changing what "descendant" refers to, I'm only changing the if statement so all parts in the model become visible. My question is how can I target only the descendant with those specific name?
old version:
local descendants = game.Workspace.grapples.grapple:GetDescendants() for index, descendant in pairs(descendants) do if descendant:IsA("BasePart") or <--delete this and keep the rest descendant.Name == "Union" or descendant.Name == "a" or descendant.Name == "b" then descendant.BrickColor = BrickColor.new("Really red") descendant.Transparency = 0 end end
new version
local descendants = game.Workspace.grapples.grapple:GetDescendants() for index, descendant in pairs(descendants) do if descendant.Name == "Union" or descendant.Name == "a" or descendant.Name == "b" then descendant.BrickColor = BrickColor.new("Really red") descendant.Transparency = 0 end end