:SetPrimaryPartCFrame messes up the rotation for some parts

Everytime i reload these items the rotation gets messed up for some reason and i have no idea how to fix it.

Before reloading:


After reloading:

How do i fix this issue?

2 Likes

Without any content or context it’s hard to say what the problem is. Please provide more information regarding the issue and provide the source for the issue.

As for rotation, CFrame can always change if it’s based off some sort of other part that has a changing orientation, on the other hand, Orientation will always set the orientation of the objects to specified vectors.

If you are basing the CFrame off a part that’s moving then that may be the issue.

2 Likes

Its not based off of a moving part. Once the block gets placed it shows that the orientation is slightly offset.
It happens randomly.

The rotation is always rounded to 90 or 180 as an example.
The rotation and position thats given in the cframe is correct, but for some reason it messes up once i use :setprimarypartcframe

1 Like

I have noticed its because i create a CFrame from the saved orientation vector3 value, but i have no idea how to fix it without saving the cframe which would increase the datacost by a lot.

1 Like

I did notice setting the cframe to a part first and then using :setprimarypartcframe with the part its cframe works, but that would make the game really slow.

First I need to know what you’re setting the CFrame to, when I say moving part I mean a basepart that may not be in the same position and can move. An example is the character, if you were to set a part’s cframe to the character then the part’s orientation will be relative to the character

I never recommend using SetPrimaryPartCFrame especially if it’s on anchored assemblies. Take a look at this bug report from all the way back in 2015:

To clarify: it’s still relevant and testable.

anchored assemblies as in all the children instances are anchored? Would using :GetBoundBox() then setting a part to the center of the model and then setting the PrimaryPart to that part help?

I have fixed the issue by setting the cframe to a regular part first and then using :setprimarypartcframe with the part its cframe.

The issue only showed up for the hoverthrusters so i have made it work via the part its cframe for the hoverthrusters only.

local newpart = Instance.new("Part") -- this is the only thing that fixes it and i have heard that it only happens to this specific block
newpart.CFrame = Rotation
Rotation = CFrame.fromOrientation(math.rad(newpart.Orientation.X),math.rad(newpart.Orientation.Y),math.rad(newpart.Orientation.Z))
newpart:Destroy()
2 Likes