> For the complete documentation index, see [llms.txt](https://vopwn55.gitbook.io/powerlang-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vopwn55.gitbook.io/powerlang-docs/libraries/services/ray.md).

# Ray

The `Ray` functionality is used for casting rays through the game environment, enabling developers to perform tasks like detecting intersections with objects. This service is essential for gameplay mechanics such as shooting, line-of-sight calculations, and physics interactions.

| **Function**                                                                                                                          | **Description**                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `findPart(Origin: Vector3, Direction: Vector3, FilterType: string, FilterDescendantsTable: {Instance}): (Instance, Vector3, Vector3)` | Casts a ray from a specified origin in a given direction and checks for intersections with parts in the game. Requires 4 arguments: `Origin` (Vector3), `Direction` (Vector3), `FilterType` ("Whitelist" or "Blacklist") to specify the filter type, and `FilterDescendantsTable` (table of Instances) to filter which parts to check against. Returns the intersected `Instance`, the intersection `Position` (Vector3), and the surface `Normal` (Vector3) at the point of intersection. |
