Hi. So with this script, I'm trying to make it so when you click a GUI button, it makes the parts in the certain model either visible or not. (on and off system). The script is correct, but I just need help making it so it selects the bricks in a model and changes their properties accordingly (instead of listing something like World.Brick1.Transparency = 1 and changing that for 20 different bricks) Any help is appreciated!
local P = script.Parent.Parent.Parent.Parent.Parent.Name
local HLoc = Workspace:FindFirstChild(P)
local On = false
function onClick(mouse)
local Helmet = HLoc:findFirstChild("Chest")
local belt = Workspace.Equipment.Chest.refvest:GetChildren()
if Helmet ~= nil and On==false then
belt.Transparency = 0
On = true
elseif Helmet ~= nil and On==true then
belt.Transparency = 1
On = false
end
end
script.Parent.MouseButton1Down:connect(onClick)

8 comments
Running into issues with that. I don't know if this would change your answer, but this is the layout of the model and other things: http://prntscr.com/bkhxfo This is the script I edited with your code: http://prntscr.com/bkhy32
Is this what the script should look like? http://prntscr.com/bkio9p
No. In the 2nd example, you would use the word 'model' in the toggle function as I had it, not refvest. Apologies for switching from an example to an actual function.
Is this correct? (http://prntscr.com/bkk13t) If so, its not working..
You never connected onClick to MouseButton1Down..
It works, however, its supposed to make a copy of the models and put it on your person, then when you click the button it changes the transparency of the stuff on you. http://prntscr.com/bkk5rm
Alright, well that wasn't a part of your question at all. I'd recommend consulting the wiki for stuff like :Clone() and welds. If this solved the problem, you should accept the answer so people know it's been answered.
After attempting to create the next part of your script, don't be afraid to ask another question if you can't quite get it.