So, my current code looks something like this.
However, when I use it, it just flies off to somewhere random. How would I fix this?
local Model = game.Workspace[Player.Name] Model.PrimaryPart = Model.Part Model:SetPrimaryPartCFrame(CFrame.fromEulerAnglesXYZ(0, 0, 90))
The problem is that CFrame.fromEulerAnglesXYZ(0, 0, 90)
returns a CFrame rotated by 90 radians (I assume you meant degrees) on the Z axis with a position of (0, 0, 0), which means that the model will be moved to (0, 0, 0).
If you wanted to set the rotation to 90 degrees, you would use this:
Model:SetPrimaryPartCFrame(CFrame.new(Model.PrimaryPart.Position) * CFrame.Angles(0, 0, math.rad(90)))
If you wanted to increase the rotation by 90 degrees, you would use this:
Model:SetPrimaryPartCFrame(Model:GetPrimaryPartCFrame() * CFrame.Angles(0, 0, math.rad(90)))
Note that CFrame.Angles
and CFrame.fromEulerAngesXYZ
take their inputs as radians, not degrees. Therefore, you must convert degrees to radians using the math.rad
function first.