Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Change a screenimage when a value changes?

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

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.