How can I store everything a function returns?

So, I have a random function that returns a random amount of variables. Is there a way to store all of these variables in a table?

example:

local randomFunction = function()
	local randomVariables = {}
	
	for i = 1, math.random(1,10) do
		table.insert(randomVariables,i)
	end
	
	return unpack(randomVariables)
end

local a,b,c,... = randomFunction()

just don’t unpack the table and return it as-is?

Well, that’s the whole question

literally just dont unpack the table

You’re already storing these values inside the randomVariables array, so just return randomVariables instead of returning the unpacked version of it. Then you only need one variable when calling randomFunction() and it will be your table.

There is no reason to unpack and after that repack your arguments if you can just index them in the array. For example if you want to obtain your “a” value then just get the first index from your new table. No need to make separate variables.

Guys, you’re not getting the question. I just want to know if this is possible or not, but it seems not

That would be pretty difficult because you would need to check for 10 different variables if they actually are a number or not and then insert them into a table. Why is it difficult? Well if you want more than 10 random variables then it starts getting really annoying to make.