I was trying to script a TV which when enabled changes the colors of the screen, and that works but when trying to turn off the TV its supposed to go completly black which it does for a second but then it continues to change the colors until the color part is at an end. Could someone help me find a way to make it stay black when turning it off? Would be really nice, thank you.
Here is a example of what I mean:
Here is the current script I have written:
local click = script.Parent
local screen = script.Parent.Parent.Parent.Screen
local Music = screen.Music
local bool = script.Parent.Parent.Parent.Active
click.MouseClick:Connect(function()
if bool.Value == false then
bool.Value = true
screen.Material = ("Neon")
Music:Play()
while bool.Value == true do
screen.Color = Color3.new(0.986267, 0.033753, 0.0367437)
wait(2)
screen.Color = Color3.new(1, 0.995499, 0.0456703)
wait(2)
screen.Color = Color3.new(0.136294, 1, 0.0328222)
wait(2)
screen.Color = Color3.new(0.0679484, 0.402289, 0.998383)
wait(2)
screen.Color = Color3.new(0.98883, 0.439139, 0.065095)
wait(2)
screen.Color = Color3.new(0.0959945, 0.508309, 0.998474)
wait(2)
screen.Color = Color3.new(1, 1, 1)
wait(2)
end
elseif bool.Value == true then
bool.Value = false
screen.Material = ("Plastic")
Music:Pause()
screen.BrickColor = BrickColor.new("Black")
end
end)
local click = script.Parent
local screen = script.Parent.Parent.Parent.Screen
local Music = screen.Music
local bool = script.Parent.Parent.Parent.Active
click.MouseClick:Connect(function()
if bool.Value == false then
bool.Value = true
screen.Material = ("Neon")
Music:Play()
while bool.Value == true do
screen.Color = Color3.new(0.986267, 0.033753, 0.0367437)
if bool.Value == true then
wait(2)
screen.Color = Color3.new(1, 0.995499, 0.0456703)
if bool.Value == true then
wait(2)
screen.Color = Color3.new(0.136294, 1, 0.0328222)
if bool.Value == true then
wait(2)
screen.Color = Color3.new(0.0679484, 0.402289, 0.998383)
if bool.Value == true then
wait(2)
screen.Color = Color3.new(0.98883, 0.439139, 0.065095)
if bool.Value == true then
wait(2)
screen.Color = Color3.new(0.0959945, 0.508309, 0.998474)
if bool.Value == true then
wait(2)
screen.Color = Color3.new(1, 1, 1)
if bool.Value == true then
wait(2)
end
end
end
end
end
end
end
end
elseif bool.Value == true then
bool.Value = false
screen.Material = ("Plastic")
Music:Pause()
screen.BrickColor = BrickColor.new("Black")
end
end)
local click = script.Parent
local screen = script.Parent.Parent.Parent.Screen
local Music = screen.Music
local bool = script.Parent.Parent.Parent.Active
click.MouseClick:Connect(function()
if bool.Value == false then
bool.Value = true
screen.Material = ("Neon")
Music:Play()
while bool.Value == true do
screen.Color = Color3.new(0.986267, 0.033753, 0.0367437)
if bool.Value == true then
wait(2)
screen.Color = Color3.new(1, 0.995499, 0.0456703)
end
if bool.Value == true then
wait(2)
screen.Color = Color3.new(0.136294, 1, 0.0328222)
end
if bool.Value == true then
wait(2)
screen.Color = Color3.new(0.0679484, 0.402289, 0.998383)
end
if bool.Value == true then
wait(2)
screen.Color = Color3.new(0.98883, 0.439139, 0.065095)
end
if bool.Value == true then
wait(2)
screen.Color = Color3.new(0.0959945, 0.508309, 0.998474)
end
if bool.Value == true then
wait(2)
screen.Color = Color3.new(1, 1, 1)
end
if bool.Value == true then
wait(2)
end
end
elseif bool.Value == true then
bool.Value = false
screen.Material = ("Plastic")
Music:Pause()
screen.BrickColor = BrickColor.new("Black")
end
end)
local click = script.Parent
local screen = script.Parent.Parent.Parent.Screen
local Music = screen.Music
local bool = script.Parent.Parent.Parent.Active
click.MouseClick:Connect(function()
if bool.Value == false then
bool.Value = true
screen.Material = ("Neon")
Music:Play()
local colors = {
Color3.new(0.986267, 0.033753, 0.0367437),
Color3.new(1, 0.995499, 0.0456703),
Color3.new(0.136294, 1, 0.0328222),
Color3.new(0.0679484, 0.402289, 0.998383),
Color3.new(0.98883, 0.439139, 0.065095),
Color3.new(0.0959945, 0.508309, 0.998474),
Color3.new(1,1,1)
}
while bool.Value == true do
for i,v in pairs(colors) do
if bool.Value == true then else break end
screen.Color = v
wait(2)
end
end
elseif bool.Value == true then
bool.Value = false
screen.Material = ("Plastic")
Music:Pause()
screen.BrickColor = BrickColor.new("Black")
end
end)
local click = script.Parent
local screen = script.Parent.Parent.Parent.Screen
local Music = screen.Music
local bool = script.Parent.Parent.Parent.Active
function ScreenColor(Color)
if bool.Value then
screen.Color = Color
task.wait(2)
end
end
click.MouseClick:Connect(function()
bool.Value = not bool.Value
if bool.Value then
screen.Material = ("Neon")
Music:Play()
while bool.Value do
ScreenColor(Color3.new(0.986267, 0.033753, 0.0367437))
ScreenColor(Color3.new(1, 0.995499, 0.0456703))
ScreenColor(Color3.new(0.136294, 1, 0.0328222))
ScreenColor(Color3.new(0.0679484, 0.402289, 0.998383))
ScreenColor(Color3.new(0.98883, 0.439139, 0.065095))
ScreenColor(Color3.new(0.0959945, 0.508309, 0.998474))
ScreenColor(Color3.new(1, 1, 1))
end
else
screen.Material = ("Plastic")
screen.BrickColor = BrickColor.new("Black")
Music:Pause()
end
end)
I know there is already a solution, but I thought I would show this anyways