Basically I got a for loop, and to initially test it I just did a print. however, when I want to do the thing it is supposed to, it doesn't. (I have used print on both for testing purposes, I know on the one that doesn't work there is another way, but for what I need it to do this is the only way)

--This is the code that works

list = {}
screen = script.Parent
headcodes = screen.Headcode
dest = screen.Destination
unit = screen.Unit

function add(okie)
    table.insert(list,okie)
    while true do
    for i,v in pairs(list) do
        print(i)
        print(v)
    end
    wait()
end
end
game.Workspace.trains.ChildAdded:Connect(add)
--This is the code that doesn't 

list = {}
screen = script.Parent
headcodes = screen.Headcode
dest = screen.Destination
unit = screen.Unit

function add(okie)
	table.insert(list,okie)
    while true do
	for i,v in pairs(list) do
		if i == 1 then
			print('1'..v)
		elseif i == 2 then
			print('2'..v)
		elseif i == 3 then
			print('3'..v)
		elseif i == 4 then
			print('4'..v)
		elseif i == 5 then
			print('5'..v)
		elseif i == 6 then
			print('6'..v)
		elseif i == 7 then
			print('7'..v)
		end
	end
	wait()
end
end
game.Workspace.trains.ChildAdded:Connect(add)

1 comment

0

Does that codes give you any errors at the console?