so, im trying to make a 2d shooter game with raycasting but the problem is, its 2d. so the ray will also use the z value to go into a direction where i dont want it to. so to do that im trying to make the ray disregard the z value.
✓ ANSWER ACCEPTED
How to get z position from mouse.hit.p?
1 answer
✓ Accepted answer
Well your issue is, Mouse.Hit returns a CFrame. You can read up on those here, but essentially they store rotation data in addition to position data. This means that you can get the Z axis of a CFrame simply by doing CFrame.Z. So your final solution would be:
local mouse = Player:GetMouse()
local z = mouse.Hit.Z
If this answer was helpful, please don't forget to mark as solution, thx c;
1 comment
0
Mouse.Hit.P returns the Position Mouse.Hit returns the CFrame. https://developer.roblox.com/en-us/api-reference/property/Mouse/Hit
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
mouse.hit.p.z ?
scriptinghelpers is not a request site.