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

Why does table.insert() error when i clearly put 2 arguments?

I'm not going to paste the entire code since it's too long but here's the part that errored.

local function makepoints(code, point)
	local points = {point}
	local distance = tonumber(string.sub(code,2))
	for i=1,(distance-1) do
		local direction = string.sub(code,1,1)
		local offset = UDim2.new(0,0,0.1*i,0)
		local createpoint = point + offset
		table.insert{points,createpoint}
	end
	return points
end

print(makepoints("A2",UDim2.new(0,0,0,0)))

Output: 18:01:17.821 - Workspace.Script:8: wrong number of arguments to 'insert' 18:01:17.821 - Script 'Workspace.Script', Line 8 - local makepoints 18:01:17.821 - Script 'Workspace.Script', Line 13 18:01:17.822 - Stack End

As you can see in line 8 i stated the table and the value. What am I missing?

2 comments

1

Wrong brackets. Use parenthesis ()

0

Thanks!

1 answer

Next time please post an answer so this does not appear on the unanswered question sort. That's the only reason I'm doing this. As funyun said, wrong brackets use table.insert(points,createpoint) instead.

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