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

Whenever I change the orientation of a part, using CFrame, it changes the position. solution?

Whenever I use CFrame.Angles (for rotation) It moves the part to the origin when I never changed the position property. How do I fix this?

The Script: local GreenPart = game.Workspace.GreenPart local NewCFrame = CFrame.Angles(0, math.rad(60), 0)

GreenPart.CFrame = NewCFrame

I would like the solution so I could further advance into my CFrame learning. Thanks.

2 comments

0

CFrame also includes the position alongside the orientation. change it to GreenPart.CFrame = GreenPart.CFrame * NewCFrame I think this works?

0

If @Dovydas1118's answer is correct, please accept it. So, everyone knows this question has been answered.

1 answer

✓ Accepted answer

When you do CFrame.Angles() you have to be careful because when you do something like this:

local greenPart = game.Workspace.GreenPart

greenPart.CFrame = CFrame.Angles(0,math.rad(60),0)

it changes the orientation, however, it also resets the position to 0,0,0. So to solve this, you should use something like this:

local greenPart = game.Workspace.GreenPart

greenPart.CFrame = greenPart.CFrame * CFrame.Angles(0,math.rad(60),0)

why did I include a * ? because multiplying CFrame is the same as adding. So not only you get your orientation, the position stays the same. (Note: Please use code block the next time you post a question, thank you.)

1 comment

0

Thank you!

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