Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Primary Part Rotation?

Asked by
k1nq 30
8 years ago

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))     
0
Is it anchored? Senor_Chung 210 — 8y
0
It is. k1nq 30 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago
Edited 8 years ago

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.

Ad

Answer this question