local function RaycastCamera(flag, playerCoords) if not playerPed then playerPed = PlayerPedId() end if not playerCoords then playerCoords = GetEntityCoords(playerPed) end local rayPos, rayDir = ScreenPositionToCameraRay() local destination = rayPos + 16 * rayDir local rayHandle = StartShapeTestLosProbe(rayPos.x, rayPos.y, rayPos.z, destination.x, destination.y, destination.z, flag or -1, playerPed, 4) while true do local result, _, endCoords, _, entityHit = GetShapeTestResult(rayHandle) if result ~= 1 then local distance = playerCoords and #(playerCoords - endCoords) -- Add specific condition for ATMs or other entity types if flag == 30 and entityHit then -- Assuming 0xAAAA is the model hash for ATMs local atmModel = 0xAAAA if GetEntityModel(entityHit) == atmModel then -- Handle ATMs separately if needed else entityHit = HasEntityClearLosToEntity(entityHit, playerPed, 7) and entityHit end end local entityType = entityHit and GetEntityType(entityHit) if entityType == 0 and pcall(GetEntityModel, entityHit) then entityType = 3 end return endCoords, distance, entityHit, entityType or 0 end Wait(0) end end