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

Why can't I save a CFrame inside a table thats inside another table?

Asked by 4 years ago
Edited 4 years ago
table.insert(save.CorFrame, v.CFrame:GetComponents())
local save = {
    CorFrame = {


        }
    }

Just errors:

20:22:10.107 - Workspace.Script:15: wrong number of arguments to 'insert'
20:22:10.107 - Stack Begin
20:22:10.108 - Script 'Workspace.Script', Line 15
20:22:10.108 - Stack End

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

The reason you're getting this error is that CFrame:GetComponents() returns more than one variable. It copies all the possible components from the CFrame and returns them.

Returns the values: x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22, where R00-R22 represent the 3x3 rotation matrix of the CFrame, and xyz represent the position of the CFrame.

If you simply want to return the CFrame itself, then you can leave off the :GetCompontents() portion. If you insist on keeping all the data from the GetComponents() portion, then you could do something like this:

v = Instance.new("Part",game.Workspace);
local save = {
    ["CorFrame"] = {

        }
    }
table.insert(save.CorFrame, {v.CFrame:GetComponents()});

I'm returning the variables inside a table that way it can save that single table in this example.

Ad

Answer this question