Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

a surface screen window transparancy changer help?

Asked by 7 years ago

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.

0
Could you please indent & have your code readable? It's hard to read & understand what's going on. TheeDeathCaster 2368 — 7y
0
it is..... popthecorn145 16 — 7y

1 answer

Log in to vote
0
Answered by
Validark 1580 Snack Break Moderation Voter
7 years ago

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)

Ad

Answer this question