How to successfully rotate Motor6D in tool

I need help rotating a Motor6D in a viewmodel that I have, when the tool is equipped. I have everything already, but no matter how I change the C0 and C1, it gives the wrong orientation in game. I tried multiplying them against itself too, but I dont understand Motor6D CFrames.

handleMotor.C0 = CFrame.Angles(90, 0, 0)
handleMotor.C1 = CFrame.Angles(0, 0, 0)

The above code does not give the correct orientation. It doesnt even change the orientation on a single axis like I want, instead the whole tool is positioned based off of that. I dont want to change the position, just the rotation of the tool. I can give more information, but I feel my problem lies in how I am changing the CFrames of the Motor6D

I can successfully set the C0 and C1 to 0, 0, 0, but if I set the C0 to 90, 0, 0, then the result actually comes out as 63.38, 180, 180. This is not what I want.

I have tried use math.rad, I have also tried setting 2 Vector3 values, 1 for Position, and 1 for Rotation, and settings a CFrame that way, which didnt error, but gave me about the same random results I was getting before. I dont see any consistencies with this property and its confusing. All I need to do is set the rotation of the C0 property in a motor6d. This has been very frustrating to figure out, and I am at a loss. This has been going on for a few hours now too lol, thanks everyone for helping out so far.

Thank you, let me know if I need to include more information.
!

This is when the rotation of the CFrame is set to 0,0,0
image_2024-05-12_145145816|690x457

This is when the rotation is set to 0,90,90. Even with math.rad, it gives the same results.

I currently have:

local handlePosition = Vector3.new(0,0,0)
local handleRotation = Vector3.new(0,90,90)
	
handleMotor.Part1 = handle
handleMotor.C1 = CFrame.new(handlePosition, handleRotation)

This gives me the second image. Even when using math.rad. Its the closest I have come so far.

1 Like

Convert it to rad

handleMotor.C0 = CFrame.Angles(math.rad(90), 0, 0)
handleMotor.C1 = CFrame.Angles(0, 0, 0)

Even using math.rad still changes the position of the tool. Im also having issues with rotation in general, even in the properties window. If I set rotation on the Z axis of a part, it will instead rotate it on the Y axis, and leave the Z value at 0. Not sure what is happening or why it is happening but my head hurts.

cframes are confusing, although the position shouldn’t change tho. that’s odd.

When only setting the cframe.angles it will reset the position cframe so you got to set the position cframe again. Can’t really make an example right now, but i hope you know what i mean.

It is definitely odd. I thought that I had understood CFrames well enough to control whether that happened or not, until I started messing with Motor6D’s for a sword.

So I have found out, that changing the C1 CFrame gives me more of what I want, but it still doesnt explain the inconsistencies in setting the rotation. Now that the position is correct, rotating it is nearly impossible. If I set the rotation to “90, 0, 0” it rotates left, if I set it to “0,90,0” it rotates backwards, and if I set it to “0,0,90” it just rotates to the left again, but its spun. Even when I use math.rad on all of those numbers.

I updated the post with any information I have figured out and included pictures to help visualize what I am trying to achieve.

You’re using the second argument in cframe.new(1,2) which is deprecated. Use cframe.lookat(currentPosition: Vector3, lookAtPosition: Vector3). I saw you’re using a a weapon so i dont recommend using cframe.lookat for this case. You should just use for example (there are more ways to do this) cframe.new(chosenPositionCoords) * cframe.angles(chosenAngleCoords). You will need to use math.rad for the cframe.angles coords if you’re working with degrees. You should just play around with the position- and angleCoords to get something you like (Also recommend only using 90 degree intervals on the angle coords to get it straight up if you wanted that).

1 Like

You are a saint. Im having to work out some other little things, but Im thankful that you came with the right answer.

May the rest of your life be full of inspiration.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.