I'm trying to make the characters arm always point towards the mouse but can't seem to get it.

What I've tried so far:

--// Vars
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local rightArm = char:WaitForChild("RightUpperArm")
local mouse = plr:GetMouse()

--// Arm moving loop
while wait() do
	local mouseHit = mouse.Hit.p

	rightArm.CFrame = CFrame.new(rightArm.Position, Vector3.new((mouseHit.X, mouseHit.Y, mouseHit.Z))
		
end

6 comments

0

Don't use while wait() do. Instead use RenderStepped of RunService.

0

Okay thanks. I changed it but instead of just the arm moving the whole player goes flying in the direction of the mouse.

0

Also just pass mouseHit instead of constructing a new Vector3 since mouse.Hit.Position is a Vector3 (dont use .p)

0

So it would just be rightArm.CFrame = CFrame.new(rightArm.Position, mouse.Hit)

0

well, Cframes have a position property with which you can get their position matrix

0

Hmm can someone show me an example of this? I’m a little lost.