Making arms follow mouse

what I tried

local mouse = player:GetMouse()
game:GetService("RunService").RenderStepped:Connect(function() 

    mouse.TargetFilter = workspace 

    player.Character.RightUpperArm.RightShoulder.C1 =CFrame.new()

    player.Character.RightUpperArm.RightShoulder.C0 =CFrame.new(0, 1.5, 0) * CFrame.Angles(math.asin((mouse.Hit.p - mouse.Origin.p).unit.y), 0, 0)

end)

Thank you for all help in advance

1 Like

I think you make the arms follow the camera.

I haven’t tested this, but you can do this:

local mouse = player:GetMouse()
game:GetService("RunService").RenderStepped:Connect(function() 
    local mousePos = mouse.Hit.Position
    local cf = CFrame.new(Vector3.new(1.5, 1, 0), mousePos)

    player.Character.RightUpperArm.RightShoulder.C0 = cf

end)

If the arms are in a weird position then you can change the Vector3.new(x, y, z) in

local cf = CFrame.new(Vector3.new(1.5, 1, 0), mousePos)
1 Like

It looks like you are using CFrame.new() to get a CFrame orientated from a position to another, you shouldn’t do this as there is a better way.

local cf = CFrame.lookAt(Vector3.new(1.5,1,0), mousePos)

I got it!
If you want to have the players hand point towards the mouse when a tool is equipped, just delete the CFrame.Angles(x, y, z) from the code.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local cam = workspace.CurrentCamera
local shoulder = player.Character.RightUpperArm.RightShoulder

game:GetService("RunService").RenderStepped:Connect(function() 
	local mousePos = mouse.Hit.Position - shoulder.Parent.Position -- Gets mouse pos relative to shoulder
	
	local cf = CFrame.lookAt(Vector3.new(1, 0.5, 0), mousePos)

	shoulder.C0 = cf * CFrame.Angles(math.rad(cf.Rotation.x + 90), math.rad(cf.Rotation.Y), 0)
end)

You also have to put this in a LocalScript.

3 Likes

I found a solution, it’s above this reply. ^^^

Unfortunately, I do not think this would work because CFrame.Rotation is a CFrame. The X property of CFrame.Rotation is just 0 because it’s only the rotation, it doesn’t include the position, which means the X Y Z properties are actually the position.

Mark the reply as the solution if it has solved your problem.

This isnt a good solution, after testing it with both R6 and R15, it doesn’t work as intended.
even after changing a few things, nope

Thank you for all the help
Everyone!
Your solution orientates the arm weirdly so it would not work how I want it to
If anyone else knows what to do help

After changing it to math.Atan it worked a bit better but it’s still not good enough for what I want
Also, I don’t really need the arm to turn left and right only up and down but both would work better

I did some more googling and I found a random pastebin with code that worked
Link:ROBLOX - Point Arm Towards Mouse - Pastebin.com
Credits to the person who made that

4 Likes

have any way to make the arms follow mouse show for everyone in server?

Yeah remote events can do it just fire it to the server