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

How do I script a Tv's on and off button?

Asked by
Kitorari 266 Moderation Voter
8 years ago
01script.Parent.ClickDetector.MouseClick:connect(function(Onclick)
02    script.Parent.BrickColor = BrickColor.new("Medium stone grey")
03    script.Parent.CFrame = CFrame.new(68.869, 78.81, -458.99)
04    script.Parent.Parent.Parent.Screen.ScreenFace.BrickColor = BrickColor.new("Institutional white")
05    wait(0.50)
06    script.Parent.BrickColor = BrickColor.new("Institutional white")
07    script.Parent.CFrame = CFrame.new(68.869, 78.81, -459.04)
08 
09end)
10 
11script.Parent.ClickDetector.MouseClick:connect(function(onclick)
12if script.Parent.Parent.Parent.Screen.ScreenFace.BrickColor == BrickColor.new("Institutional white")
13        then script.Parent.Parent.Parent.Screen.ScreenFace.BrickColor = BrickColor.new("Really black")
14end
15end)

I'm trying to make it so every other time the tv's power button is clicked, then it'll turn off.

I've tried using elseif, but it says I have to close off a script, even though it's already closed off.

Help would be great. =u=' ((Strangely, the output isn't saying anything..))

1 answer

Log in to vote
1
Answered by 8 years ago

Use that as a guide

01debounce  = false
02 
03script.Parent.ClickDetector.MouseClick:connect(function(click)
04    if debounce then
05        debounce = false
06        script.Parent.Parent.Parent.Screen.ScreenFace.BrickColor = BrickColor.new("Really black")
07    else
08        debounce = true
09        script.Parent.Parent.Parent.Screen.ScreenFace.BrickColor = BrickColor.new("Institutional white")
10    end
11end)
Ad

Answer this question