Make arms follow mouse R6

I am wanting to make it so the arms follow the mouse, so if your mouse is up, your arms go up, etc.

The issue is that my game is R6, and my current script only works for R15.

I have tried more DevForum, but there all for R15, and the ones that are R6 don’t seem to work.

My R15 code in local script in StarterPlayerScripts (Works for R15 but not R6)

local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

local plr = Players.LocalPlayer
local mouse = plr:GetMouse()

local char = plr.Character or plr.CharacterAdded:Wait()-- the character (you can probably easily get a reference to it somehow)
local leftShoulder = char:WaitForChild("LeftUpperArm"):WaitForChild("LeftShoulder")
local rightShoulder = char:WaitForChild("RightUpperArm"):WaitForChild("RightShoulder")



local function rotateArms()
	local dir = mouse.Hit.Position - mouse.Origin.Position
	local angle = math.atan2(dir.Y, math.sqrt(dir.X^2+dir.Z^2))
	local rotationCf = CFrame.Angles(angle, 0, 0)
	local orgLeftTransform, orgRightTransform = leftShoulder.Transform, rightShoulder.Transform
	local orgLeftPos, orgRightPos = orgLeftTransform.Position, orgRightTransform.Position
	leftShoulder.Transform, rightShoulder.Transform = rotationCf*(orgLeftTransform-orgLeftPos)+orgLeftPos, rotationCf*(orgRightTransform-orgRightPos)+orgRightPos
end
RunService.Stepped:Connect(rotateArms)

Thanks!

2 Likes

These rigs are totally different, R6 only uses 6 parts and R15 uses 15:

What I can see here is that you want to modify the orientation of the motor 6d inside of the arms, if you want to do the same for the R6 rig, all the motor 6d of the R6 rig are inside of the torso.

Example:

local Character = Player.Character

local Left = Character.Torso:WaitForChild('Left Shoulder')
local Right = Character.Torso:WaitForChild('Right Shoulder')

--{ do stuff }--
2 Likes

Just set the arm’s CFrame look at to mous.hit the position can be any thing or nothing so it stays the same. You don’t need all that math just use look at.

1 Like

Also, R6 uses completely different names for its arms and stuff so those won’t work.

1 Like