ok so im making a smart house and in the smart house the hole house is going to be controlled by a touch seen or more than one. anyway here is my script
function blind () if workspace.window1.Transparency == 0 then workspace.window1.Transparency = 0.6 elseif workspace.window1.Transparency == 0.6 then workspace.window1.Transparency = 0 end if workspace.window2.Transparency == 0 then workspace.window2.Transparency = 0.6 elseif workspace.window2.Transparency == 0.6 then workspace.window2.Transparency = 0 end end script.Parent.MouseButton1Click:connect(blind)
so im trying to make a toggle script where when i click the button once it chages the windows transparency to 0 and then when i click it again it changes it to 0.6 well it changes it to 0 but it wont change is to 0.6.
Use a variable to keep track of its state.
local windows = {workspace.window1, workspace.window2} local amountOfWindows = #windows local transparent = windows[1].Transparency == 0 function blind() local Transparency if transparent then transparent = false Transparency = 0.6 else transparent = true Transparency = 0 end for i = 1, amountOfWindows do windows[i].Transparency = Transparency end end script.Parent.MouseButton1Click:Connect(blind)