Raycast from mouse, 2d to 3d

Hello, im trying to be able to click on entity with mouse and get that entity ID, converting 2d coords to 3d coords or raycast from mouse if possible.
Any idea how i can convert 2d to 3d using GetCursor()

function GetCursor() 
  local sx, sy = GetActiveScreenResolution()
  local cx, cy = GetNuiCursorPosition()
  local cx, cy = (cx / sx) + 0.008, (cy / sy) + 0.027
  return cx, cy
end

Or is there a other way to make it simpler?

Hey boy i did implement something like that in my server recently, take a look of this post

https://forum.cfx.re/t/release-standalone-raycast-system-interaction-with-the-ped-and-the-car-through-the-cursor/1591352