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

Turn On/Turn Off Window not working?

Asked by 9 years ago

So I am making something like a reception desk. The person manning the desk can click the window to make it transparent or not. It would also label "Click to start(/end) interviews" to prompt the player to open the window if they are ready for an interview.

function onClicked(playerWhoClicked)
    script.Parent.Transparency = 1 
    script.Parent.Parent.TurnOn.Decal.Transparency = 1
    function onClicked(ClickedAgain)
        script.Parent.Transparency = 0
        script.Parent.Parent.TurnOff.Decal.Transparency = 0
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

I don't know how to make it work. It would go transparent, but if you click it again, it wouldn't work.

3 answers

Log in to vote
1
Answered by 9 years ago

The problem is in the last lines you forgot to run the 2nd function

      end
script.Parent.ClickDetector.MouseClick:conect(onClicked)
end
0
:P chill22518 145 — 9y
0
I meant you forgot to run the script chill22518 145 — 9y
0
wait lol I meant you forgot to run the 2nd function chill22518 145 — 9y
0
You can edit your answers and comments and stuff if you need to correct something, you know. Lightdrago 95 — 9y
0
I did chill22518 145 — 9y
Ad
Log in to vote
1
Answered by 9 years ago

You could use a numbervalue in the brick. In my opinion, that would be easier. It could look like this:

script.Parent.ClickDetector.MouseClick:connect(function()
    if script.Parent.NumberValue.Value == 0 then
        script.Parent.Transparency = 1
        script.Parent.TurnOn.Decal.Transparency = 1
        script.Parent.NumberValue.Value = 1
    else 
        script.Parent.Transparency = 0
        script.Parent.TurnOn.Decal.Transparency = 0
        script.Parent.NumberValue = 0
end)
Log in to vote
1
Answered by
iaz3 190
9 years ago

local Open = true function onClicked(playerWhoClicked) -- If you don't want to know who clicked, you don't need this. script.Parent.Transparency = Open and 1 or 0 -- If open is true, then transparency is 1 script.Parent.Parent.TurnOn.Decal.Transparency = Open and 1 or 0 -- If open is true, then transparency is 1 Open = not Open -- Sets the value of open to it's opposite. end script.Parent.ClickDetector.MouseClick:connect(onClicked)

This should work.

0
Edit: Changed "True" to "true" iaz3 190 — 9y

Answer this question