Model:PivotTo() is not working properly (HELP)

I have been trying to figure out the problem for hours but with 0 success…i have a local script which does :

task.wait(5)

local startCframe = CFrame.new(3.557, 7.372, 15.031) * deg(12, 102, -17)

workspace.S10:PivotTo(startCframe)

S10 is a humanoid rig(anchored) and the deg is a function which returns CFrame Angles:

local function deg(x, y, z)
	return CFrame.Angles(
		math.rad(x),
		math.rad(y),
		math.rad(z)
	)
end

When I test the game…after 5 seconds..the rig gets teleported to this :

The orientation is not matching with what I put in the code…There are no other scripts that is handling S10 too…

Please help me :folded_hands:

Maybe this will work:

local function deg(x, y, z)
	return CFrame.Angles(
		math.rad(x),
		math.rad(y),
		math.rad(z)
	)
end

task.wait(5)

local startCframe = CFrame.new(3.557, 7.372, 15.031) * deg(12, 102, -17)

local model = workspace:WaitForChild("S10")

if not model.PrimaryPart then
	model.PrimaryPart = model:FindFirstChildWhichIsA("BasePart")
end

model:PivotTo(startCframe)

It likely depends on what you are chosing as a PrimaryPart for your Model, I’d try having the RootPart be the PrimaryPart instead of the Head, as it’s probably more centered inside the Model

The root part is HRP…i am using that as reference

Yes but your PrimaryPart is the Head, as shown in the image that you sent, PivotTo() uses the PrimaryPart

Nope..it is not working. I even put a print statement to check. Although it printed..the Model seems to be stubborn and only rotates to : -2.478, 101.745, -5.255

Oh my bad…that was an oversite in my part. I changed it to hrp and it didnt make any difference. for some reason it stays on the rotation : -2.478, 101.745, -5.255

Depending on the usecase of the rig why not just unachor it and instead use collssion groups to make sure no one or thing can interact with it? Maybe it’s not working due to it being anchored :person_shrugging:

CFrame.Angles(rx, ry, rz) uses XYZ order, while the Properties panel shows YXZ order. So the values won’t match even if the rotation is the same.

Also, with big angles (like 102°), you can get gimbal lock, which makes the values look even more random.

So -2.478, 101.745, -5.255 isn’t a bug it’s just the same rotation shown in a different format.

local function deg(x, y, z)
    return CFrame.fromEulerAnglesYXZ(
        math.rad(x),
        math.rad(y),
        math.rad(z)
    )
end

task.wait(5)
local startCframe = CFrame.new(3.557, 7.372, 15.031) * deg(12, 102, -17)
workspace.S10:PivotTo(startCframe)

Now the angles will match what you see in Properties.

Also check

Your primaryPart is set to head. PivotTo() uses the PrimaryPart, so the model rotates around that.


the orientation panel also shows the XYZ format
The primary part has been set to HRP

I figured about the issue…It seems there was a malicious bug in other script(taken from tooblox for testing) which caused this. I had to create a new baseplate project and it seems everything worked out as intended.

For people who replied to this post, i thank you for you’re patience and time.