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

Why are these rotations acting weird?

I'm not going to past my script here since it's over 100 lines, but here is an example of what I am doing.

Part1 - Orientation = -68.91, 44.01, 44.01

Part2 - Recently cloned

I want to set Part2's Orientation to the same as Part1. Now through my script process, I have Part1's Orientation as X, Y, and Z (separate variables).

I then go to set Part2's Position and Orientation to Part1's...

local partCFrame = CFrame.new(PosX,PosY,PosZ)

local rotation = CFrame.fromEulerAnglesXYZ(math.rad(RotX),
									math.rad(RotY),
									math.rad(RotZ))

partCFrame = partCFrame * rotation

Now the Position works perfectly fine, but the Orientation of Part2 gets skewed somehow and I can't figure out why.

Part2 - Orientation = -42.15, 69.57, -16.96

Here is a picture of how it looks, the Blue is Part1, the Green is Part2. gyazo.com/64563902fa28379887c64adfa3221007

1 answer

✓ Accepted answer
local rotation = CFrame.fromEulerAnglesXYZ(math.rad(RotX),
	                                    math.rad(RotY),
	                                    math.rad(RotZ))

Your rotation is already in radians first of all. Get rid of math.rad to begin with, then we can work from their if your problem resumes. Another thing, you could do:

local CFrame = CFrame.new(Part1.Position) * Part2.CFrame:toEulerAnglesXYZ

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