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 6 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:

01local cd = script.Parent.ClickDetector
02local screen = script.Parent.Parent.Screen
03local pump = screen.Shotgun
04local gui = screen.SurfaceGui
05local image = gui.ImageLabel
06local value = script.Parent.Parent.Channel.Value.Value
07image.Visible = true
08 
09gui.Background.Visible = true
10screen.Gunfire:Play()
11screen.Music:Play()
12 
13while true do
14    wait()
15    if value == 1 then
16        --Animation for channel 1
17    else
18    if value == 2 then
19        --Animation for channel 2
20        end
21    end
22end

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

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

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

and then change the final code to this:

1while wait() do
2    if value.Value == 1 then
3        --Animation for channel 1
4    else
5    if value.Value == 2 then
6        --Animation for channel 2
7        end
8    end
9end
Ad

Answer this question