Roblox "..." parameter

I have one simple question, where does the “…” parameter in functions stand for?
image
I’ve tried printing it and it seems that “…” just takes the variable name.
Why is it possible for it to be 3 dots and not more, or less? Do those dots server a purpose other than being a parameter name?

6 Likes

It means the function can take any number of arguments.
For example:

local function warnMessage(text, ...)
	print("warning: "..text)
	warn(...)
end

This will pass the first argument into the call to print, then send all remaining arguments into warn

You can also extract arguments by casting it to a table:

local function list(...)
	local stuff = {...}
	for i, v in ipairs(stuff) do
		print(i.." : "..v)
	end
end
8 Likes

As Blokav said, it means the function can take any number of arguments, which are all represented by “…”. They are called tuples. To “extract” the arguments from tuples, you could turn it into a table by doing {...}, the values being the arguments in the same order that you called the function with. Alternatively, you could use the select() function from Lua to get certain arguments from them.

1 Like
1 Like