Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I print the contents of a function?

I'm wondering whether or not its possible to print the unknown contents of a function. For example, if you have:

function aFunction(...)
	print(1)
end

How do I extract the line, "print(1)" from the function, so I can print it afterwards? Thank you in advance for your help.

1 answer

We can use variadic arguments, represented by '...' to help us with this

table1 = {}
function appendToTable(tab, ...)
	local args = {...}
	for i, v in pairs(args) do
		table.insert(tab, v)
	end
end
appendToTable(table1, "xD", ":D", "lol")

for _,v in pairs(table1) do
	print(v)
end

Source: Variadic arguments

This discussion is preserved as it was. New answers, comments, and votes are closed.