Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Primary Part Rotation?

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))		

2 comments

0

Is it anchored?

0

It is.

1 answer

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.