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.
The problem is in the last lines you forgot to run the 2nd function
end script.Parent.ClickDetector.MouseClick:conect(onClicked) end
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)
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.