There is no need to provide second (argument #2) at all. Neither PivotTo()
nor SetPrimaryPartCFrame()
require second argument.
All they need is a CFrame
.
To clear up confusion, CFrame
“includes” both position and rotation. You have not provided the code that errors, but I assume it is something like this:
--bad code example
part.CFrame = CFrame.new(part.Position,CFrame.Angles(0,0,math.rad(90)))
Many people make this mistake. This code will error, as the second argument to the CFrame.new()
constuctor has to be a Vector3
, in this case, a point in space where the front face of a part should face. This particular constructor has been replaced by CFrame.LookAt()
, but I digress.
What you really need is to apply rotation to the model, without changing its position. To rotate a part on its axis, without changing its position, multiply part’s CFrame
by CFrame.Angles()
:
model:PivotTo(model:GetPivot() * CFrame.Angles(0,0,math.rad(90)))
If you want to rotate the part on the world axis use:
model:PivotTo((CFrame.Angles(0, 0, math.rad(90)) * (model:GetPivot() - model:GetPivot().Position) + model:GetPivot().Position)
So your final code should look something like this (for the rotation on model’s axis)
--local script
local newCFrame = workspace.Model:GetPivot() * CFrame.Angles(0,0,math.rad(90))
game.ReplicatedStorage.partevent:FireServer(newCFrame)
--server script
game.ReplicatedStorage.partevent.OnServerEvent:Connect(function(plr, newCFrame)
workspace.Model:PivotTo(newCFrame)
end)