Different action for hitting a click detector a 2nd time

you’re not stupid. your code would still look like this:

   if isTvOn  then
		--TODO: turn tv off
		isTvOn = false
		
	else
		--TODO: turn tv on
		isTvOn = true  
	end

just inside a mousebutton1click event instead of MouseClick event.

isTvOn = not IsTvOn is another way of changing isTvOn to true/false, but it does it in one line instead of two.

how it works is if isTvOn is true it sets isTvOn to not true and not true means false. vice versa for if isTvOn was false.

you can write it either way, but maybe stick to isTvOn = true / isTvOn = false for now since you’re just learning it.

2 Likes