Rotating a whole model around a point

Hi all,
I know there are other topics relating to this but none of the solutions seemed to work correctly in this case, so your help would be greatly appreciated :).

I am trying to rotate a gate around a certain point (the pole), but when the script runs, it does not rotate as expected.

Default State (Orientation 0, 20, -90):
image

Desired Position (Orientation 0, -70, -90) :
image

Position after script runs:
image

This is my current script, with the pole set as the primary part to the model the script, and the rest of the gate, is in.

	local RGate = script.Parent
	RGate:SetPrimaryPartCFrame(RGate.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(-70), 0))

Also, the way this model moves currently is teleporting from one position to the other, but I would like it to be a smooth animation between the two.
Any help on what I am doing wrong here would be fantastic, thanks!

SetPrimaryPartCFrame is deprecated, and instead you should use PivotTo() .

Try something like this?

Model:PivotTo(Model:GetPivot() * CFrame.Angles(0, math.rad(-70), 0)) ) 

And for an animation try this?

local YPosition = 20
repeat
YPosition -= 0.1 
Model:PivotTo(Model:GetPivot() * CFrame.Angles(0, math.rad(-0.1), 0)) ) 
task.wait(0.05)
until YPosition <= -70 

I’m on phone so I haven’t been able to test this.

1 Like

Thanks, that worked perfectly with a couple of tweaks so thank you for the help, it’s very helpful!! :).

1 Like

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