Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Trying to make a TV able to be turned on/off?

So i was trying to make a simple TV where you click a button then an image pops up and once you press the off button the image goes away. Heres the script i attempted to use:

script.Parent.MouseClick:connect(function() game.Workspace.Screen.Decal.Texture = "Decal ID" end)

i couldent get the decal to pop up and ive made sure that it was approved before i set it in the script. After this i would have wanted to add an off button but since i cant get past this part i cant really see myself wrapping my head around an off button. this is a very basic TV i wanted to make so i might make a new question soon about how to make a while loop TV able to be turned off and on. anyways the question above is all i need help with at the moment.

1 answer

✓ Accepted answer

It's pretty simple. Just add 2 debounces, one being the ID, and the other being the power off and on. Also, add a ClickDetector to the button.

DecalID = YourIDHere -- Change the YourIDHere to the decal ID you want it to be.
local power = false

script.Parent.ClickDetector.MouseClick:connect(function()
	if power == false then
		power = true -- Turns on the TV
		workspace.Screen.Decal.Texture = 'rbxassetid://' .. DecalID
	else
		power = false -- Turns off the TV
		workspace.Screen.Decal.Texture = ''
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.