Automatically expands and collapses BillboardGui UI on parts tagged with 'SlateInteraction' based on camera distance and look direction — no per-part scripting required.
ProximityService runs on a Heartbeat loop and checks every managed part each frame. It uses hysteresis (separate expand/shrink thresholds) to prevent flickering at the boundary. A dot-product check ensures the player is also looking toward the part — distance alone is not enough to trigger expansion.
Initialize once in a LocalScript
Open the Tag Editor in Studio (View → Tag Editor) and apply the 'SlateInteraction' tag to any BasePart. The service picks it up immediately via CollectionService — no restart required.
Each tagged part must have a BillboardGui child containing two frames: Small (always visible at range) and Expanded (the panel that slides open when near). The service drives Expanded.Size and Expanded.BackgroundTransparency. A pre-made one is available in the SlateUI Services folder under Intereaction for easy setup.
Hierarchy example
The constants EXPAND_DISTANCE, SHRINK_DISTANCE, EXPAND_DOT, and SHRINK_DOT are defined at the top of ProximityService. Increase EXPAND_DISTANCE for wider activation zones, or lower EXPAND_DOT to allow activation from a wider angle.
Default threshold values for reference
| Prop | Type | Default | Description |
|---|---|---|---|
| Init | () -> () | — | Scans for all tagged parts, sets up CollectionService listeners, and connects the Heartbeat loop. |
| Update | () -> () | — | Called automatically each Heartbeat. Can also be called manually if you need frame-locked updates. |