Can't make model rotate

Hey everyone,

The problem:
I can’t rotate the car(model) right

Gif:
https://gyazo.com/2443625ddcf59f08c7a6b47c8a2f11db

My Code:
	local Car = PoliceCar:Clone()
	Car.Name = player.Name.."-Police"
	local randomSpawn = PoliceSpawns[math.random(1,#PoliceSpawns)]
	Car:SetPrimaryPartCFrame(CFrame.new(randomSpawn.Position))
	
	Car.Parent = game.Workspace:FindFirstChild("PoliceCars")
	wait(0.3)
	player.Character:MoveTo(Car.Chassis.VehicleSeat.Position)

And I have not idea how to rotate the model

Thanks for reading. :grinning:

1 Like

To rotate a model you need to add a CFrame.Angles at SetPrimaryPartCFrame() it would look something like this

Car:SetPrimaryPartCFrame(CFrame.new(randomSpawn.Position) * CFrame.Angles(0,0,0))
and you would need to change the CFrame.Angles value to whatever position you want the model to rotate to, they need to be radians but you can simply use math.rad() with the degrees you want it to rotate.

1 Like

Hello, to rotate models now you don’t need a primarypart!

Now you should use :PivotTo() and :GetPivot() instead of :SetPrimaryPartCFrame and :GetPrimaryPartCFrame which will directly get the model CFrame.

Now, to rotate the model you will need to use Euler Angles and these functions, an example code would be:

local Model = workspace.Model

Model:PivotTo(Model:GetPivot() * CFrame.fromEulerAnglesXYZ(0, math.rad(90),0)) -- in radians
3 Likes