How can I make this table (Weld C1) into an CFrame

^ is an picture of the code, what I was doing is making an Helicopter sliding door for my new game that’s coming out soon.

v is an picture of the error.

1 Like

As you can see in the error, CFrames require a Vector3 for their first argument (CFrame position). Your `closeddoorinfo` is just a table with a bunch of values of which none are Vector3s! What are you trying to do here? How and why are you adding these values to your `closeddoorinfo` table? We have nothing to work with to help you as you just put a picture and an error with almost no information about what your trying to do and how!
Make sure to add as much detail as possible when creating a post so we can help you quicker and easier!

My bad, as you can see where it says at
“weld.C1 = CFrame.new({closeddoorinfo})”

(thats the error by the way)

What I was trying to do is to reset the door to its original position
AKA making it closed. What I’m trying to do is to know how to put it back to it’s original position with this table, as it is it’s stored C1 position

Try replacing it with this?
`weld.C1 = CFrame.new(unpack(closeddoorinfo))`

Doesn’t work, but gives an different error.

What do all the values in the table represent? How do they convey the old position of the door?

As I said already, they represent the original position of the door.

What I want to do, is to store this value, and be able to transition back to this Weld C1 Position

Instead of a table, you should be using a `CFrame` value. This method will work with your table or a `CFrame` value though.

Just do `weld.C1 = closeddoorinfo`. You dont need to create a new CFrame

1 Like
``````local ClosedDoorCFrame = CFrame.new(
-0.20003357,
0.569989681,
-0.0200195313,
1,
0,
-8.52651283e-14,
0,
1,
1.01643954e-20,
-8.52651283e-14,
1.01643954e-20,
1
)

module.OpenDoor = function()
weld.C1 = ClosedDoorCFrame
for i = 1,5 do
wt()
weld.c1 = CFrame.new(weld.c1 * Vector3.new(0, 0, 1))
end
end
``````
1 Like

`ClosedDoorCFrame` can be changed to whatever he wants.

It’s not multiplying by lookvector

From the CFrame api reference.
`Returns the Vector3 transformed from Object to World coordinates.`

1 Like

The property `weld.c1` requires a `Vector3` as it’s type. At the moment, all the solutions involve setting it to a CFrame.

Change the line `weld.C1 = CFrame.new(...)` to the following:

``````weld.C1 = Vector3.new(...)
``````

Replace “…” with your unpacking code, and make sure your coordinates are still correct.

The C1 property of welds are CFrames, not Vector3.

I did not see that on the reference, so fair point, but the errors given throughout the post state that a Vector3 was required, not CFrame.

Vector3 excpected got CFrame”

So first of all, this CFrame can hold simpler values, numbers like `-8.52651283e-14` are extremely close to 0, and might as well be evaluated as such:

``````CFrame.new(
-0.20003357, 0.569989681, -0.0200195313, -- Position
1, 0, 0, -- Right Vector
0, 1, 0, -- Up Vector
0, 0, 1 -- Look Vector
)
``````

This is surprisingly similar to an identity CFrame:

``````CFrame.new(
0, 0, 0,
1, 0, 0,
0, 1, 0,
0, 0, 1
)
``````

Therefore, we can use the simplified 3-number constructor to produce this:

``````CFrame.new(-0.20003357, 0.569989681, -0.0200195313)
``````

And there would be no need to add the 9 extra numbers to the full constructor, since this is what the 3-number constructor provides by default.

New code should probably look like this:

``````local ClosedDoorCFrame = CFrame.new(-0.20003357, 0.569989681, -0.0200195313)

--...
``````

The major issue here that nobody has caught, because nobody here mentioned the line number, is that CFrames cannot be added together! You can only either multiply `CFrames` together or add `Vector3s` to them (in which case both will yield a CFrame).
That would make the new function look like this:

``````module.OpenDoor = function()
weld.C1 = ClosedDoorCFrame
for i = 1, 5 do
wt()
weld.C1 = weld.C1 * CFrame.new(0, 0, 1) -- HERE
end
end
``````

or alternatively:

``````module.OpenDoor = function()
weld.C1 = ClosedDoorCFrame
for i = 1, 5 do
wt()
weld.C1 = weld.C1 + Vector3.new(0, 0, 1) -- HERE
end
end
``````

Both will yield the same result, although this will not hold true in almost any other situation, as outlined by the post below me.

@regularwolf’s answer will also yield the right CFrame:

I fixed the CFrame coordinates, they were so wrong…

6 Likes

I just want to mention that this is only true due to the rotational component of `ClosedDoorCFrame` (and thus `weld.C1`) having “identity” rotation. For any CFrame that is not world axis aligned you would get different results.

1 Like