Issue with Motor6D Orientation

Hi, I’m encountering an issue when trying to connect two parts using a Motor6D. In my code, I set C1 to have a specific orientation (90, -90, 0). However, when running the game, the properties of the Motor6D display a different orientation.

Below is the relevant code block:

UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if gameProcessed then
		return
	end

	if input.KeyCode == Enum.KeyCode.F then
		if not CurrentItemSelected then return end
		local ItemModule = GunsModule[CurrentItemSelected.Name]
		
		local PATH_MODEL:Model = ItemModule.PATH_MODEL:Clone() -- This is a model
		PATH_MODEL.Parent = ViewModel
		local Part0 = ViewModel:FindFirstChild("Right Arm")
		local HandleMotor6D = Instance.new("Motor6D")
		HandleMotor6D.Parent = Part0
		HandleMotor6D.Name = "Handle"
		HandleMotor6D.Part0 = Part0
		HandleMotor6D.Part1 = PATH_MODEL.PrimaryPart.Handle
		HandleMotor6D.C0 = CFrame.new(Part0:FindFirstChild("AttachArm").Position)
		HandleMotor6D.C1 = CFrame.Angles(math.rad(90), math.rad(-90), math.rad(0))

		CurrentItemSelected:Destroy()
		CurrentItemSelected = nil
	end
end)

When running the game, these are the properties generated for the Motor6D. The issue lies in the orientation of the C1 attribute:

Key Details:

  1. Purpose of the Code: This script creates a Motor6D to connect a cloned model (PATH_MODEL) to the ViewModel.
  2. C1 Configuration: I’m using CFrame.Angles with values (90, -90, 0) to set the desired orientation.
  3. Unexpected Behavior: Despite configuring C1, the orientation shown in the game is different from what I set.

Questions and Context:

  • Am I setting C1 incorrectly?
  • Could the relative position between Part0 and Part1 be altering the orientation?
  • Is there any additional transformation required to make C1 work as intended?

I’d appreciate any guidance or solutions to this issue. Please let me know if you need more details.

1 Like

Whenever you’re doing Motor6D orientation, you should get the old position of C1. and then multiply with the CFrame.Angle Orientation.

Example Code:

local Motor6DOrigin  = Motor6D.C1

Motor6D.C1 = Motor6DOrigin * CFrame.Angles(0, 0, 0)

I hope this was helpful!

1 Like

I already tried as you said and it didn’t work, it’s still the same.

1 Like

When it is running, if you manually set it to what you wanted does it work?

1 Like

Of course, when doing it manually, the orientation is correctly placed in the game.

1 Like

Oh wait it is correct. That’s orientation which is different to what CFrame.Angles does

You might want to use CFrame.fromOrientation(math.rad(90), math.rad(-90), math.rad(0))

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