Why is my character not looking at the cursor [solved]

Like the title has described the problem, my character isn’t looking at the mouse position.
I used commonly used trigonometric function Atan2(), which returns me angles i need to know, but it seems like it doesn’t work. can somebody tell me what’s wrong?

The equation

	script.LookAngle.Value = math.atan2(-Input.getMousePosition().X,-Input.getMousePosition().Y) * (180/math.pi)

Module

function HotkeyModule.getMousePosition()
	return Vector2.new(Mouse.X,Mouse.Y)
end

CameraControl

Character:SetPrimaryPartCFrame(CFrame.new(HumanoidRootPart.Position) * CFrame.Angles(0,math.rad(script.Parent.InputControl.LookAngle.Value),0))	

try adding 90 degrees to the y axis

1 Like

It didn’t help

Thanks for you help, i solved it myself

tell us and future readers how you solved it


Just trasnformed it into 3d vector and used the if statement to check if the Angle is smaller than zero so i can turn it back to a positive number.

I think you got it reversed:

math.atan2(-Input.getMousePosition().X,-Input.getMousePosition().Y)

Correct version:

math.atan2(-Input.getMousePosition().Y,-Input.getMousePosition().X)


Notice it’s Y then X, not the other way around.