My character isn't facing the mouse correctly

Hey guys. I’m making a top down shooter and my character won’t face the mouse correctly. The mouse icon isn’t aligned with the laser icon. When i move the mouse around in a circle, the distance from the laser to the mouse icon gets larger. It should actually stay the same length apart from each other.
Here is my script:

local function UpdateCam()
		if Character then
			if HumanoidRootPart then
				local rootPosition = HumanoidRootPart.Position + Vector3.new(0, 20, 0)
				local playerPosition = HumanoidRootPart.Position 

				CamController.Position = rootPosition 
				CamTurner.CFrame = CFrame.new(rootPosition, playerPosition) 
				Camera.CFrame = CamPart.CFrame

				if not Sprinting then
					Mouse.TargetFilter = workspace
					local Direction = (Mouse.Hit.Position - Character["Right Arm"].Position).Unit
					HumanoidRootPart.CFrame = CFrame.new(HumanoidRootPart.Position, Vector3.new(Mouse.Hit.p.X, HumanoidRootPart.Position.Y, Mouse.Hit.p.Z))			
				end
			end
		end
	end
	RunService:BindToRenderStep("SidescrollingCamera", Enum.RenderPriority.Camera.Value + 1, UpdateCam)

Image from Gyazo

What can i do to fix this? It might have somethign to do with the Mouse.Hit, but what other options do i have?

1 Like

works perfectly fine?

i dont see any issues in the video

Me neither. Mind elaborating? Cause it looks great to me.

Hey guys. The mouse icon isn’t aligned with the laser icon. As you can see when i move around in a circle, the distance from the laser to the mouse icon gets larger.

I’m not sure what the problem is still. But it might be because the mouse.Hit is actually the laser itself?

Mouse.Hit has a TargetFilter so it avoids everything in the workspace. The problem is the character doesn’t align with the mouse.

I still don’t see it. Maybe send a video of you not moving the mouse?

Image from Gyazo

As you can see my bullets are aligned with my character. You can tell by the direction they fly in. The laser is not. You can tell by seeing that the laser doesn’t cross with the mouse.

Change the CFrame like this:

CFrame.Angles(numX,numY,numZ)

This really doesnt work, i apologise

2 Likes