How can I access the orgin position of a model in a script?

so I need to set the origin position of a model to 0,0,0 how can I do this because the origin position property has a space in it and it wont let me access it I tried this code can someone help?

game.Workspace.TableLamp.OrginPosition = Vector3.new(0,0,0)
9 Likes

Here’s how you index a property with a space in the name:


workspace.TableLamp["Origin Position"] = Vector3.new(0, 0, 0)

However, it is not possible to change this property via Lua code.

If you want to move the model to the origin you could set the PrimaryPart property to a part inside the model and run the following code:


workspace.TableLamp:SetPrimaryPartCFrame(CFrame.new(0, 0, 0))

Another option would be to use :MoveTo() but if there are any obstructions in the way then the model will be moved up.


workspace.TableLamp:MoveTo(Vector3.new(0, 0, 0))

11 Likes

I have tried this but It just looked for an item inside that with the name orgin position but let me try again

2 Likes

yeah the orgin position gave me an error

Origin Position is not a valid member of Model "Workspace.TableLamp"

So I guess ill try move to

1 Like

So using move to does solve one problem but I still need to access orgin orientation and I cant do that

3 Likes

I believe you can use Origin Position by using the model’s PivotTo() function. Although this way requires you to use CFrame instead of Vector3 starting off. In order to get the Origin Position of a part you can use GetPivot() as well.

4 Likes

Instead of Origin Position use Position.

1 Like

You CAN’T set model positions, you can only use pivots and :SetPrimaryPartCFrame().

6 Likes