Ipairs not doing anything

I’m trying to run functions in table order but “ipairs” is not doing anything at all. It works just fine with “pairs” but its all out of order.

local An = {
	R1 = function()
		Run(1,5)
	end;
	
	R2 = function()
		Run(2,7)
	end;
	
	R3 = function()
		Run(3,3)
	end;
	
	R4 = function()
		Run(4,6)
	end;
	
	R5 = function()
		Run(5,7)
	end;
}


for i, v in ipairs(An) do
	wait(1)
	v()
end


Ummm wheres the commas? ignore

I used the “;” instead of commas.

Dont think tht works atleast in my knowledge.

Pretty sure ipairs only loops through arrays or dictionary numbers

1 Like

Wdym? Hes obviously using an array.

Its not there the index’s are named. R1 is a string not a number

1 Like

Ohhh yea my bad, i didnt notice it b4.

Use this:

local An = {
	[1] = function()
		Run(1,5)
	end;
	
	[2] = function()
		Run(2,7)
	end;
	
	[3] = function()
		Run(3,3)
	end;
	
	[4] = function()
		Run(4,6)
	end;
	
	[5] = function()
		Run(5,7)
	end;
}


for i, v in ipairs(An) do
	wait(1)
	v()
end

It runs in order

1 Like

how do I run this in order? because “pairs” is random

local An = {
	function()
		Run(1,5)
	end,
	
	function()
		Run(2,7)
	end,
	
    function()
		Run(3,3)
	end,
	
	function()
		Run(4,6)
	end,
	
	function()
		Run(5,7)
	end,
}


for i, v in ipairs(An) do
	wait(1)
	v()
end

Shud work.

1 Like

Use pairs 4 dictionaries while looping.