Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

a surface screen window transparancy changer help?

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.

2 comments

0

Could you please indent & have your code readable? It's hard to read & understand what's going on.

0

it is.....

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.