Hello! I'm making a script where when I click on a button, the property of multiple parts with the same name gets changed, but I can't make it work. What have I done wrong?
local ClickDetector = script.Parent.ClickDetector ClickDetector.MouseClick:Connect(function(clicked) for i,v in pairs(workspace:GetChildren()) do if v:IsA("Part") then if v.Name == "Name" then if v.Transparency == 0.8 then v.Transparency = 1 elseif v.Transparency == 1 then v.Transparency = 0.8 end end end end end)
local ClickDetector = script.Parent:WaitForChild("ClickDetector") local partname = "transparencypart" ClickDetector.MouseClick:Connect(function() for i,v in pairs(workspace:GetChildren()) do if v.Name == partname and v.ClassName == "Part" then if v.Transparency == 1 then v.Transparency -= .2 else v.Transparency += .2 end end end end)