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

Change a screenimage when a value changes?

Asked by 5 years ago

I'm currently trying to make an animated TV with changeable channels, the animation portion works but changing the channels does not. I'm using a value that can be changed from one to two, and then number cannot go past two. Output tells me nothing, and I've tried various different parts for it without succeeding. Here's the script:

local cd = script.Parent.ClickDetector
local screen = script.Parent.Parent.Screen
local pump = screen.Shotgun
local gui = screen.SurfaceGui
local image = gui.ImageLabel
local value = script.Parent.Parent.Channel.Value.Value
image.Visible = true

gui.Background.Visible = true
screen.Gunfire:Play()
screen.Music:Play()

while true do
    wait()
    if value == 1 then
        --Animation for channel 1
    else
    if value == 2 then
        --Animation for channel 2
        end
    end
end

I tried doing "while value == 1 do" or "while value == 2 do" but that didn't work.

Any help would be greatly appreciated, thanks!

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

Change local value = script.Parent.Parent.Channel.Value.Value to

local value = script.Parent.Parent.Channel.Value

and then change the final code to this:

while wait() do
    if value.Value == 1 then
        --Animation for channel 1
    else
    if value.Value == 2 then
        --Animation for channel 2
        end
    end
end
Ad

Answer this question