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
7 years ago
script.Parent.ClickDetector.MouseClick:connect(function(Onclick)
    script.Parent.BrickColor = BrickColor.new("Medium stone grey")
    script.Parent.CFrame = CFrame.new(68.869, 78.81, -458.99)
    script.Parent.Parent.Parent.Screen.ScreenFace.BrickColor = BrickColor.new("Institutional white")
    wait(0.50)
    script.Parent.BrickColor = BrickColor.new("Institutional white")
    script.Parent.CFrame = CFrame.new(68.869, 78.81, -459.04)

end)

script.Parent.ClickDetector.MouseClick:connect(function(onclick)
if script.Parent.Parent.Parent.Screen.ScreenFace.BrickColor == BrickColor.new("Institutional white")
        then script.Parent.Parent.Parent.Screen.ScreenFace.BrickColor = BrickColor.new("Really black")
end
end)

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 7 years ago

Use that as a guide

debounce  = false

script.Parent.ClickDetector.MouseClick:connect(function(click)
    if debounce then
        debounce = false
        script.Parent.Parent.Parent.Screen.ScreenFace.BrickColor = BrickColor.new("Really black")
    else
        debounce = true
        script.Parent.Parent.Parent.Screen.ScreenFace.BrickColor = BrickColor.new("Institutional white")
    end
end)
Ad

Answer this question