I want to have my script recognize when the ‘TV is ON’ so when clicked again it will do the opposite, ‘Turn OFF’.
Part of the script that isn’t working…
function onMouseClick()
if tvScreen.SurfaceGui.VideoFrame.Visible = true then
powerButton.BrickColor = BrickColor.new('Really red')
tvScreen.SurfaceGui.VideoFrame.Visible = false
print("TV OFF")
end
I know it’s the ‘true then’ part which obviously isn’t correct and I can’t find what I need to do to fix this issue. I don’t normally do scripting.
Entire Script
local clickDetector = script.Parent
local powerButton = script.Parent.Parent
local tvScreen = script.Parent.Parent.Parent.Screen
function onMouseClick()
if tvScreen.SurfaceGui.VideoFrame.Visible = true then
powerButton.BrickColor = BrickColor.new('Really red')
tvScreen.SurfaceGui.VideoFrame.Visible = false
print("TV OFF")
end
powerButton.BrickColor = BrickColor.new('Lime green')
tvScreen.SurfaceGui.VideoFrame.Visible = true
print("TV ON")
end
clickDetector.MouseClick:connect(onMouseClick)