Mouse.Hit.p not accurate?

Hello DevForum!

I’m making a gun, but the Mouse.Hit.p doesn’t seem to return the correct position… Or did something else go wrong?

Thanks in advance!

The issue you’re having is almost definitely due to not accounting for the GUI Inset. I remember having the exact same issue before too and its frustrating that Mouse.Hit doesn’t account for it by default! Just subtracting/adding its vertical difference should do the trick.

1 Like

Thanks for your reply! Although, it still doesnt change a lot. Any other suggestions?

are u using bodyvelocity? if so change the p and maxforce to math.huge
sorry the video is not loading for me

No i’m not. I’m just returning the position from the mouse and using that as the direction of the ray.

Could you show your code? It’s most likely something to do with your script

Oh so either use Mouse.Hit.p to completely bypass the error, or use Camera:ScreenPointToRay() or Camera:ViewportPointToRay to find the world position

1 Like