SlateUI
DocsComponentsGitHub
Install SlateUI Plugin
SlateUI
DocsComponentsGitHub
Install SlateUI Plugin

Components

  • installation
  • button
  • inputs
  • notification
  • progressbar
  • loading
  • proximity
  • router
Component

ProximityService

Automatically expands and collapses BillboardGui UI on parts tagged with 'SlateInteraction' based on camera distance and look direction — no per-part scripting required.

Overview

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

luau
1
2
3
4
5
-- LocalScript in StarterPlayerScripts
local ProximityService = require(game.ReplicatedStorage.SlateUI.ProximityService)
 
ProximityService.Init()
-- That's all — it now manages every part tagged "SlateInteraction"

Tagging Parts

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.

GUI Hierarchy 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

luau
1
2
3
4
-- Part (tagged "SlateInteraction")
-- └─ BillboardGui
-- ├─ Small (Frame — the always-on chip)
-- └─ Expanded (Frame — the detail panel)

Customizing Thresholds

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

luau
1
2
3
4
local EXPAND_DISTANCE = 8 -- studs to trigger expand
local SHRINK_DISTANCE = 9 -- studs to trigger shrink (hysteresis gap)
local EXPAND_DOT = 0.85 -- camera must be ~32° or less off-axis to expand
local SHRINK_DOT = 0.80 -- shrinks if angle exceeds ~37°

API

PropTypeDefaultDescription
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.