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

How to Pass in Table as a function's Arguments?

function printabc(a,b,c)
	print(a,b,c)
end

local list = {1,2,3}
printabc(list)

The above code prints "table:1234567 nil nil"

Is there anyway way, without saying "print(list[1], list[2], list[3])", that the above format will work?

1 answer

✓ Accepted answer

###You can't print a table. You can unpack it though.

local function printabc(a, b, c)
    print(a, b, c)
end

local list = {1, 2, 3}

printabc(unpack(list)) -- will unpack the table and print its elements 

1 comment

0

Oh thank god. Awesome!

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