Help with motor6d's

im trying to point my arms towards the mouse, it works perfectly for the look vector but as soon as i turn my character to the left or right or behind, it prevents my rotation from acting normally.

im also not sure about where the x,. y, z axises of the motor6d faces in general.

i have no idea what is going on so if someone knows i would really appreciate it! :slight_smile:

local torso = c:WaitForChild("Torso")
local rightArm = c:WaitForChild("Right Arm")
local rightShoulder:Motor6D = torso:FindFirstChild("Right Shoulder")
local originalC0 = rightShoulder.C0
local originalC1 = rightShoulder.C1

gun.Equipped:Connect(function()
	
	connection = runService.Stepped:Connect(function()
		local playerMouse = p:GetMouse()
		local mouse = uis:GetMouseLocation()
		local unitRay = camera:ScreenPointToRay(mouse.X, mouse.Y)
		local direction = (playerMouse.Origin.Position - playerMouse.Hit.Position).Unit
		local params = RaycastParams.new()
		params.FilterDescendantsInstances = {c}
		params.FilterType = Enum.RaycastFilterType.Exclude
		
		rightShoulder.C0 = rightShoulder.C0:Lerp(originalC0 * CFrame.Angles(0, math.asin(direction.X), -math.asin(direction.Y)) , 0.4)

			local x,y,z = rightShoulder.C0:ToOrientation()
			--print(playerMouse.Hit.Position)
			--print("X:"..math.deg(x), "Y:"..math.deg(y), "Z:"..math.deg(z))
			--print(c.PrimaryPart.CFrame.LookVector)
	end)
end)

the problem starts at 0:12

(i really hate motor6d’s with a passion, they’re so hard to understand lol.)

1 Like

Search the forums for ‘aim arms to cursor’, ‘point arms at mouse’ or similar types of phrases. There are a lot of similar posts in the forums that have solved this issue.

1 Like

yeah i somehow figured it out last night but thanks a million for the help as always Scott

solution 4 anyone who needs help w this!!

local p = game.Players.LocalPlayer
local gun = script.Parent
local c = p.Character
local camera = workspace.CurrentCamera
local runService = game:GetService("RunService")
local connection = nil

local serverEvent:RemoteEvent = gun:FindFirstChild("serverEvent")
local torso = c:WaitForChild("Torso")
local rightArm = c:WaitForChild("Right Arm")
local rightShoulder:Motor6D = torso:FindFirstChild("Right Shoulder")
local originalC0 = rightShoulder.C0

gun.Equipped:Connect(function()


	connection = runService.Stepped:Connect(function()
		local playerMouse = p:GetMouse()
		local mouseCF = c.PrimaryPart.CFrame:ToObjectSpace(playerMouse.Origin).LookVector

		local CF = originalC0 * CFrame.Angles(0,-mouseCF.X * 1.4, mouseCF.Y * 1.4)
		serverEvent:FireServer(CF)

		local x,y,z = rightShoulder.C0:ToOrientation()

	end)
end)

gun.Unequipped:Connect(function()
	if connection then
		connection:Disconnect()
		rightShoulder.C0 = originalC0
		connection = nil
	end
end)

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