How do you make the player look at the mouse?

So i’m trying to make it so that when a player fires a gun, they look at the mouse aka the target position. Now I’m having trouble doing this, my script below is how i attempted it. Basically what i did was try to make the HRP rotate towards the mouse but it isn’t working. How would I do this?

char.HumanoidRootPart.CFrame = CFrame.Angles(0,0,math.rad(tonumber(mouse.Hit.p)))

It keeps coming back saying “Expected number got Vector3” so I added the tonumber function but that seems to also not work.

This post has been written about too many times.

Please do not make posts without looking if there was a post similar to the one you’ve already posted about.

Here is a solution provided by CleverSource, for this same issue, but very descriptive and correctly written;

3 Likes

I know there’s already a solution above but i just wanted to point out that you should be using .Position instead of . p .