Why doesn't this follow the PrimaryPart?

I made a script that moves a model when you move with W,A,S,D,Q,E,C,R,B so its like flying. The parts ARE going with the PrimaryPart when it moves but when I rotate the part it doesn’t follow, aswell as when I press B it doesn’t follow since B is supposed to bring you back to the ground.

This is what it looks like when I try to rotate it or press B, the thing thats lower is the Primary Part.


As stated it will follow it when I use W,S,E,Q which brings it forward, backward, up, down but if I rotate or press B it doesn’t.

Notes: Every part is welded appropriately, the PrimaryPart is assigned, the only thing anchored is the PrimaryPart and I have a seperate model which works exactly the same and rotates correctly, this one just doesn’t for some reason.

3 Likes

try use Model:PivotTo(newCFrame) instead

is this doing Model.PrimaryPart:PivotTo(newCFrame) or Model:PivotTo(newCFrame)?

Model:PivotTo() is correct. It moves everything in the model

1 Like

I tried it and it did rotate it but it also looked like it was in orbit Untitled - Clipped with Medal.tv

Edit: I forgot to put my code:

ship.Parent:PivotTo(ship.CFrame.Rotation * CFrame.fromOrientation(0,math.rad(70),0))

the ship is marked as a primarypart, not the model so ship.parent is the model

Try model:PivotTo(model.PrimaryPart.CFrame*CFrame.Angles(0,[put angle to rotate by in radians],0))

I’m pretty sure I put it in right

	ship.Parent:PivotTo(ship.CFrame*CFrame.Angles(0,10,0))

The link broke but it is doing the same thing as before

1 Like

I think the problem is with the pivot offset in the model, try ungrouping and re-grouping the model and test it again

that kind of worked! The only problem now is that it makes me slightly up everytime i do it.

Use ship.Parent:GetPivot() instead of ship.CFrame.

2 Likes

btw 10 radians is very large, if you want to rotate by 10 degrees do math.rad(10)

2 Likes

get the pivot of the model instead of the CFrame of the PrimaryPart

ship.Parent:PivotTo(ship.Parent:GetPivot() * CFrame.Angles(0,math.rad(15),0))

That worked! Althought I had done something different by switching constraints from a Weld to a Hinge, your solution still worked so I’ll mark yours as the solution.

1 Like