At the moment i have This
Box1 = script.Parent function turnGhostly() if Box1.Transparency == 0 then Box1.Transparency = 0.5 end end Box1.ClickDetector.MouseClick:connect(tÂurnGhostly)
But how Would i go about making this for a model and not just a brick and how would i make it switch on another model? Like this --Model one --Model two
to --Model one --model two
Bold Model is the one that is not Transparent.
Don't know if this makes very much sense first time posting here; so let me know if i should improve my question.
you would do that like this:
box = script.Parent box2 = game.Workspace:FindFirstChild("Model2") box.ClickDetector.MouseClick:connect(function() -- connection line and makes the function all in one for i,v in pairs(box:GetChildren()) do -- v now equals all the children of box wait() if v.Transparency then -- the clickdetector is inside the model, so it will only do this if v(the current child) has the transparency property if v.Transparency == 0 then box2.Transparency = 0 v.Transparency = .5 else v.Transparency = 0 -- if it's not 0, then make it 0 box2.Transparency = .5 end end end end)
and ta-da, if you don't know what all of these things that have been used are, check the wiki.
also, if you want box2 to be clickable as well, just change the variables a little
The other code is highly inefficient.
local box=script.Parent local visibleBox=--path to box that will become visible; box.ClickDetector.MouseClick:connect(function() --Make the parts invisible for index,value in pairs(box:GetChildren()) do --So what we are doing here is looping through each part, making value the current part if value:IsA'BasePart' then --Checking if it's a part value.Transparency=1 end end --Make the visibleBox visible for index,value in pairs(visibleBox:GetChildren()) do if value:IsA'BasePart' then value.Transparency=0 end end end) --[[ Also, if you don't know about Transparency, it's a integer that is between 0 and 1. If you want it a higher number just do something like this: Transparency=1/num Also, transparency is like a bar, when it's at 1, it's fully visible while at 0 it's completely invisible. ]]