How to see how many arguments are being pased in function(...)

I want to see how many arguments are being pased but dont know how please help me

function CreateParts(...)
    print(...)
end

CreateParts()

you can’t, but you can pass a table as arguments
and do #table and you get the amount of values

Thats not what I want because I want to create loads of parts using …

it’s literally the same, otherwise there’ no other way…

You can use select:

function CreateParts(...)
	print(select('#',...)) -- 3
end

CreateParts(4,3,2)
2 Likes

So what is select and what does it do I seen it somewhere

The variadic argument takes all of the passed arguments and gives them that name. In order to see what is the length of it, try doing the following:

function CreateParts(...)
     local args = {...}
     print(unpack(args)) -- what is in the table (will print "hi" and "ok" for ex)
     print(#args) -- will give you the length.
end

CreateParts("hi", "ok")

It is possible, you just need to loop through the table you get and create the parts.

function CreateParts(...)
    local args = {...}
    for i,v in pairs (args) do
         local part = Instance.new("Part")
         Part.Parent = workspace
    end
end

select is documented, you can pass a number to get arguments after a certain index or pass '#' to get the total number of arguments.