Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

Log in to vote
0
Answered by
BiIinear 104
5 years ago

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)
Ad

Answer this question