mouse.Hit.p vs mouse.Hit

Hello!
So why would you use mouse.Hit.p instead of mouse.Hit? As far as I know mouse.Hit returns a CFrame and mouse.Hit.p returns a Vector3. So why can’t you just keep it mouse.Hit?

Even DevHub tells you that you should use mouse.Hit.p but why?

2 Likes

Well, you can use CFrame or Vector3, which are the same basically since you can get the X, Y, and Z values from both. The only thing you would need to use mouse.Hit.p for is that it is easier to compare magnitudes since using CFrame, you would have to go (Vector3.new(mouse.Hit.X,mouse.Hit.Y,mouse.Hit.Z)-(Other Vector3 position)).Magnitude, so it is more efficient to do (mouse.Hit.p-Other Vector3 position).Magnitude, so there is not that much of a difference when using mouse.Hit and mouse.Hit.p

4 Likes

Mouse.Hit is more accurate when animating or moving PrimaryParts.

2 Likes

While the post has been solved, Mouse is now less meant to be used than UserInputService. You can do UserInputService:GetMouseLocation() and camera:ScreenPointToRaycast() now, as well as getting input objects’ positions.

Those are not in CFrames though like Mouse.Hit.

3 Likes