How do I set a model's orientation to another models orientation?

I have two items: a model and another model. I want the model’s orientation to always be the same as the other model’s orientation. Unfortunately, by changing the CFrame, it just keeps adding the orientation and makes the model spin.

while wait() do
	local x, y, z = workspace.OtherModel:GetPivot():ToOrientation()
	local main = workspace.MainModel:GetPivot()
	workspace.MainModel:PivotTo(main * CFrame.Angles(x, y, z))	--This makes the model spin
end

Can’t you just add an AlignOrientation object?

Does it need to be Anchored and CFramed?
AlignOrientation can be used if one of the Parts can be unanchored.

I’m not a pro, but are you supposed to be multiplying main * the value of the other Part, or adding it?

If using CFrames is required then these may give you more information:
<CFrames | Roblox Creator Documentation
<CFrame | Roblox Creator Documentation
<Object and World Space | Roblox Creator Documentation

Also, Roblox recommends task.wait() instead of wait() now

1 Like

Both of the parts are anchored and are moved and rotated with a script. I am trying to fix it with AlignOrientation, no success as of now, though.

Do you mind showing me an example of AlignOrientation?

Here’s a video on it:

1 Like

Issue is, attachments only work for BaseParts, so how would I add attachments to models?

What about putting the attachments in the HumanoidRootPart, or the primary part.

I got it to work. Unfortunately, it does nothing, as both parts are anchored and it is not an option to unanchored them. Any thoughts on how I can work around it?

That’s why I asked if one of the parts was unanchored.

I see you didn’t check the links I posted about changing your CFrame calculation?
If it’s not rotating the way you want it’s the calculation.

I tried working with ToWorldSpace() that I have read about from the link you’ve sent – it returned the same result, spinning. What do you mean by “calculation”? Can you be more in detail?

Also, I need to be multiplying the CFrame in order to change the rotation, adding it would change the position.

Change the way you calculate the CFrame Orientation values.
Like I said, I’m not a pro.
Would CFrame.new work?

I just searched and found this post. Not sure if it’s what you need though:

CFrame.new worked! I create a new CFrame with the old CFrame’s value and add the new orientation. Thank you so much!

2 Likes

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