Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 8 years ago

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?

1
Wrong brackets. Use parenthesis () funyun 958 — 8y
0
Thanks! YourStoneMaster 10 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago

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.

Ad

Answer this question