I want to see how many arguments are being pased but dont know how please help me
function CreateParts(...)
print(...)
end
CreateParts()
I want to see how many arguments are being pased but dont know how please help me
function CreateParts(...)
print(...)
end
CreateParts()
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)
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.