How to Change a Model's Pivot


Hello, developers!
I’m working with a model in Roblox Studio, and I’m facing an issue related to its pivot point. My goal is to change the model’s pivot to a specific point within it so that position and rotation transformations are applied based on this new pivot.

I’m aware that Roblox Studio restricts the direct modification of the Pivot property through a script. However, I know that the PivotTo() method can be used to work around this. The challenge is figuring out how to make the code reference the exact point I want as the pivot. Here’s an example of the desired pivot point:


Model Details and Hierarchy

Here’s the model I’m working with:

And here’s its hierarchy:

Screenshot 2025-01-23 100354

The model PrimaryPart is set to the piece called Wall, so there’s no issue with that. However, I need the pivot to be at the specific point shown earlier, not at the model center, which is the default behavior.


Current Attempt

I’ve tried using PivotTo() in several ways. Here’s one approach I tested:

local CFrameFinal = (CFramePos * CFrameOrientation)
model:PivotTo(CFrame.new(-6, 0, 0) * CFrameFinal)

With this code, I almost achieved my goal: the model starts at the desired pivot position, but when I try to change the orientation, it rotates around the model’s center instead of the chosen pivot point.


What I Want to Achieve

  1. I want the model’s pivot to be based on a specific point (as shown in the image above).
  2. Position and rotation transformations should occur relative to this new pivot point.
  3. This change should be dynamic through scripting, not a manual adjustment.

Key Points

  • I understand the limitations of directly modifying the pivot property.
  • My current approach involves using PivotTo() since it seems the most appropriate method.
  • The model PrimaryPart is set to the piece Wall, which should help with some calculations.

If anyone has a solution or suggestions on how to achieve this precisely, I’d greatly appreciate it. Let me know if you need more details or have any questions.

Thank you in advance!

1 Like

I think the documentation could do better regarding the position, origin, pivot, and the relations between a model and its parts. Looks like PivotTo() is meant to move the model, in a way that its pivot is located at specified point. To change where the pivot is within a model you want to be setting PivotOffset of its primary part.

Alternatively, you could use a dummy part as the model primary part, and then position its actual body relative to that any way you like.

2 Likes

It is true that the documentation does not explain these issues very well, but I discovered how to use it correctly, basically if I have a model:

local CFrameFinal = CFramePosition * CFrameOrientation
model.PrimaryPart.PivotOffset = CFrame.new(0,0,6)
model.PrimaryPart:PivotTo(CFrameFinal)

With this code the model will move to the CFrameFinal position but from the Pivot that was assigned to it before using PivotTo()

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.