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.
01 | function onClicked(playerWhoClicked) |
02 | script.Parent.Transparency = 1 |
03 | script.Parent.Parent.TurnOn.Decal.Transparency = 1 |
04 | function onClicked(ClickedAgain) |
05 | script.Parent.Transparency = 0 |
06 | script.Parent.Parent.TurnOff.Decal.Transparency = 0 |
07 | end |
08 | end |
09 |
10 | 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.
The problem is in the last lines you forgot to run the 2nd function
1 | end |
2 | script.Parent.ClickDetector.MouseClick:conect(onClicked) |
3 | end |
You could use a numbervalue in the brick. In my opinion, that would be easier. It could look like this:
01 | script.Parent.ClickDetector.MouseClick:connect( function () |
02 | if script.Parent.NumberValue.Value = = 0 then |
03 | script.Parent.Transparency = 1 |
04 | script.Parent.TurnOn.Decal.Transparency = 1 |
05 | script.Parent.NumberValue.Value = 1 |
06 | else |
07 | script.Parent.Transparency = 0 |
08 | script.Parent.TurnOn.Decal.Transparency = 0 |
09 | script.Parent.NumberValue = 0 |
10 | end ) |
1 | local Open = true |
2 |
3 | function onClicked(playerWhoClicked) -- If you don't want to know who clicked, you don't need this. |
4 | script.Parent.Transparency = Open and 1 or 0 -- If open is true, then transparency is 1 |
5 | script.Parent.Parent.TurnOn.Decal.Transparency = Open and 1 or 0 -- If open is true, then transparency is 1 |
6 | Open = not Open -- Sets the value of open to it's opposite. |
7 | end |
8 |
9 | script.Parent.ClickDetector.MouseClick:connect(onClicked) |
This should work.