How to make gun points toward mouse (i spent over few hours for looking for solution)

You can write your topic however you want, but you need to answer these questions:
1.I wat to gun to rotate where mouse is on Y axis (x is already done by roblox itself caus eit just rotates with chaar)

  1. I have no idea how to do it

  2. I spent few hours and found nothing ill understand

Can you just make the gun face the camera?

I have no idea how to when i try to use cframe my scripts dont work

i have something like this:
''lua
hrp.CFrame = CFrame.lookAt(hrp.CFrame.Position, Vector3.new(mouse.Hit.Position.X, hrp.CFrame.Position.Y, mouse.Hit.Position.Z))

lua’’
but i have no idea how to change it to work on Y not X

Surround your Lua Code block with: ```

hrp.CFrame = CFrame.lookAt(hrp.CFrame.Position, Vector3.new(mouse.Hit.Position.X, hrp.CFrame.Position.Y, mouse.Hit.Position.Z))

They mean like this:

```

hrp.CFrame = CFrame.lookAt(hrp.CFrame.Position, Vector3.new(mouse.Hit.Position.X, hrp.CFrame.Position.Y, mouse.Hit.Position.Z))

```


This is something that is well documented and wanted, if you don’t understand something, I’d suggest learning basic Lua, if you haven’t already.