pesde goatsoft / lucy

useProximity

Lucy.useProximity tracks whether the player's character is within distance studs of a BasePart, Attachment, Model or Vector3, with hysteresis so it does not flicker on the boundary. Every useProximity in an app shares one Heartbeat loop that stops when the last watcher stops.

Usage

local near = Lucy.useProximity(app, workspace.Booth.Console, {
    distance = 10,
    hysteresis = 1,
    lineOfSight = false,
})
ArgumentTypeDefaultWhat it is
appApprequiredThe app
targetBasePart | Attachment | Model | Vector3requiredWorld position or instance (or getter)
options.distanceMaybeRef<number>?10Activation radius in studs
options.hysteresisnumber?1Extra studs required to leave once active
options.lineOfSightboolean?falseRequire an unobstructed raycast from the character
options.origin(() -> Vector3?)?character rootCustom origin getter (useful in specs)

Returns { active, distance, check }.

Example: showing a Dance Floor prompt

local nearFloor = Lucy.useProximity(app, workspace.DanceFloor, { distance = 18 })

Lucy.watch(nearFloor.active, function(inside)
    floorStatus(if inside then "On the floor" else "Lobby")
end)