Roblox Interaction Systems: Building ProximityPrompt Doors, Pickups, and Keycards That Validate on the Server

Nearly every interactive moment in a Roblox experience starts the same way: a player walks up to something, a small prompt fades in, and they press a key. Doors, loot crates, vending machines, keycard readers, quest givers and light switches all share that single gesture, which is why the ProximityPrompt ends up in nearly every place file.
That said, the convenience of the prompt hides a trust problem. The Triggered event tells your server that a player pressed the key, but it says far less than most scripts assume about where that player was standing, how long they held the button, or how many times they pressed it in the last second.
Our concierge desk regularly works through requests for ready-made pieces — a key-press GUI here, a door toggle there, a pickup that grants an item. Every one of those features rests on the same pattern, and this guide lays it out as one server-side validation module you can keep open while you wire doors, pickups and keycard gates.
Keep in mind that this guide sits alongside our existing material rather than repeating it. The Roblox anti-exploit guide covers RemoteEvent hardening in general and the Roblox quest systems guide covers objective tracking, while the focus here is the narrow seam between a prompt firing and the server acting on it.
A ProximityPrompt fires Triggered on the server with the player who pressed it, but the server should still verify range, hold time and cooldown itself. Treat the event as a request, never as proof.
How ProximityPrompts Actually Fire
Before writing validation, it helps to be precise about what the engine does on its own. A ProximityPrompt is an instance you parent to a BasePart, an Attachment or a Model, and the engine handles the presentation: showing the prompt when a player is close, drawing the key hint, and filling the hold ring.
The properties you will touch most often include:
- MaxActivationDistance. The radius, in studs, inside which the prompt appears for a player, with a default of 10. It governs visibility and triggering on the client, which is exactly why the server cannot treat it as a guarantee.
- HoldDuration. How many seconds the player must hold the key before Triggered fires, where 0 means a single press. Hold times suit actions you want to feel deliberate, such as cracking a vault or reviving a teammate.
- RequiresLineOfSight. When true, which is the default, the prompt hides if geometry blocks the view between the camera and the prompt. Again, this is a presentation decision made on the client.
- Exclusivity. Chooses whether one prompt shows per key (OnePerButton), one shows in total (OneGlobally), or every prompt in range shows at once (AlwaysShow). Dense rooms full of pickups usually want OnePerButton so players are not buried in key hints.
- KeyboardKeyCode and GamepadKeyCode. The bindings, which default to E and ButtonX. Touch players tap the prompt itself, provided ClickablePrompt stays enabled.
- ActionText and ObjectText. The two labels, such as "Open" and "Vault Door." Remember that values set on the server replicate to every client, so they are the wrong place for per-player messages.
All of these properties shape what a player sees and when their client is allowed to fire. None of them, on their own, should decide what the server does.
Why The Server Has To Recheck Every Trigger
When a player completes the input, their client reports it and the server fires Triggered with that Player as the argument. That is convenient, since you get a real Player object without writing your own RemoteEvent, yet the input still originated on a machine you do not control.
In fact, common exploit executors ship a helper that fires a prompt directly, and the failure modes developers describe are consistent. Whether a given tool reproduces every client signal varies by tool and by engine update, which is exactly why your server should insist on checking for itself.
Here is what an unguarded prompt lets through:
- Range bypass. A player triggers a door, chest or shop counter from across the map. Your handler runs as if they were standing at it.
- Hold skipping. A five-second vault hold completes the instant the player presses the key. Any balance you built around that delay disappears.
- Trigger spam. A script fires the same prompt as fast as the network allows. Each trigger that reaches your handler can grant currency, play a sound for the whole server, or start another tween.
- Double claims. Two honest players trigger the same pickup a moment apart and both receive the item. No exploit is required, only a handler that yields before it marks the pickup as taken.
Note that the last item happens to well-behaved players too. A validation layer earns its keep even in an experience nobody is attacking.
The comparison below maps each threat to the property the client controls and the check that closes it:
| Threat | What the client controls | Server check | When the check fails |
|---|---|---|---|
| Range bypass | MaxActivationDistance, character position | HumanoidRootPart distance to the prompt, plus slack | Trigger ignored, no state change |
| Hold skipping | HoldDuration, hold timing | Server-observed hold start versus Triggered time | Trigger ignored, hold start cleared |
| Trigger spam | Trigger frequency | Per-player, per-prompt cooldown on os.clock | Trigger ignored, cooldown unchanged |
| Double claims | Nothing — timing alone | Claimed or Busy attribute set before any yield | Second trigger sees the flag and exits |
| Missing item | Local Tools, local GUI state | Server inventory record for the keycard | Denial message to that player only |
The four checks that matter are distance, hold time, cooldown and object state. Each runs on the server after Triggered fires and each fails closed, so a rejected trigger simply does nothing.
The PromptGuard Module
The module below lives in ServerScriptService as a ModuleScript named PromptGuard. It exposes one function you call for every interactive object, bind, plus the individual checks in case a feature needs to compose them differently.
-- ServerScriptService/PromptGuard (ModuleScript)
local Players = game:GetService("Players")
local PromptGuard = table.create(0)
local RANGE_SLACK = 4 -- studs of latency allowance
local HOLD_SLACK = 0.15 -- seconds of timing allowance
local holdStarts = table.create(0) -- player -> prompt -> os.clock()
local lastUse = table.create(0) -- player -> prompt -> os.clock()
local function bucket(store, player)
local b = store[player]
if not b then
b = table.create(0)
store[player] = b
end
return b
end
local function promptPosition(prompt)
local parent = prompt.Parent
if parent:IsA("Attachment") then
return parent.WorldPosition
elseif parent:IsA("BasePart") then
return parent.Position
elseif parent:IsA("Model") then
return parent:GetPivot().Position
end
return nil
end
local function rootOf(player)
local character = player.Character
if not character then return nil end
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid or humanoid.Health <= 0 then return nil end
return character:FindFirstChild("HumanoidRootPart")
end
function PromptGuard.inRange(player, prompt)
local root = rootOf(player)
local target = promptPosition(prompt)
if not root or not target then return false end
local limit = prompt.MaxActivationDistance + RANGE_SLACK
return (root.Position - target).Magnitude <= limit
end
function PromptGuard.heldLongEnough(player, prompt)
if prompt.HoldDuration <= 0 then return true end
local starts = bucket(holdStarts, player)
local started = starts[prompt]
starts[prompt] = nil -- one hold authorizes one trigger
if not started then return false end
return os.clock() - started >= prompt.HoldDuration - HOLD_SLACK
end
function PromptGuard.cooldownReady(player, prompt, seconds)
local last = bucket(lastUse, player)[prompt]
return last == nil or os.clock() - last >= seconds
end
function PromptGuard.bind(prompt, cooldown, handler)
prompt.PromptButtonHoldBegan:Connect(function(player)
bucket(holdStarts, player)[prompt] = os.clock()
end)
prompt.Triggered:Connect(function(player)
if not prompt.Enabled then return end
if not PromptGuard.inRange(player, prompt) then return end
if not PromptGuard.heldLongEnough(player, prompt) then return end
if not PromptGuard.cooldownReady(player, prompt, cooldown) then return end
bucket(lastUse, player)[prompt] = os.clock()
handler(player)
end)
end
Players.PlayerRemoving:Connect(function(player)
holdStarts[player] = nil
lastUse[player] = nil
end)
return PromptGuard
The snippet builds its tables with table.create(0) rather than literal syntax, which behaves identically in Luau. If you type your modules, the Luau type checking guide shows how to annotate the handler signature so a typo in a callback surfaces in Studio instead of in production.
The Range Check
The range check measures from the HumanoidRootPart to the prompt's world position, which depends on the parent type. An Attachment reports WorldPosition, a BasePart reports Position, and a Model reports its pivot.
RANGE_SLACK adds four studs on top of MaxActivationDistance because a moving player's server position trails what they see on their own screen. At the default WalkSpeed of 16 and roughly 150 milliseconds of delay, a player covers about 2.4 studs before the server hears from them, and at a sprint speed of 32 that figure doubles to roughly 4.8.
Accordingly, tune the slack against your fastest legitimate movement rather than leaving it at four. Too little slack rejects honest players who interact while running past, and too much quietly hands back the range an exploiter wanted.
Add three to five studs of slack to MaxActivationDistance for the server range check. Latency means a moving player's server position trails their screen, and zero slack rejects honest triggers.
The Hold Check
The hold check records the moment the server sees PromptButtonHoldBegan and compares it to the moment Triggered arrives. A trigger with no recorded start, or one that arrives faster than HoldDuration minus a small slack, is rejected.
What's more, the check consumes the recorded start, so each hold authorizes exactly one trigger. Be aware that this design relies on the hold-began signal reaching the server, so confirm it in a two-player Team Test before you lean on it for a high-value action.
Cooldowns And Ordering
The cooldown is tracked per player and per prompt using os.clock, and the timestamp is written only after every other check has passed. This ordering matters, since a failed range check should never lock an honest player out of a door they then walk up to.
For instance, a 0.75-second cooldown on a door feels instant to a person yet caps any script at under two actions per second. Pickups and shop counters can usually tolerate a full second or more.
Cleanup
PlayerRemoving clears both tables for the departing player, so the module does not grow over a long server session. If your experience streams in thousands of temporary prompts, also clear entries from each prompt's Destroying event so stale keys do not linger until the player leaves.
Wiring A Door Toggle
A door is the simplest case, and it is also the one where shared state matters most. The script below slides an anchored panel open or closed and flips the prompt's label so every player sees the same door state.
local TweenService = game:GetService("TweenService")
local ServerScriptService = game:GetService("ServerScriptService")
local PromptGuard = require(ServerScriptService.PromptGuard)
local door = workspace.Doors.VaultDoor
local panel = door.Panel
local prompt = panel.ProximityPrompt
local closedCFrame = panel.CFrame
local openCFrame = closedCFrame * CFrame.new(0, 0, -4)
local info = TweenInfo.new(0.6, Enum.EasingStyle.Quad)
PromptGuard.bind(prompt, 0.75, function(player)
if door:GetAttribute("Busy") then return end
door:SetAttribute("Busy", true)
prompt.Enabled = false
local isOpen = door:GetAttribute("Open") == true
local goal = table.create(0)
goal.CFrame = if isOpen then closedCFrame else openCFrame
local tween = TweenService:Create(panel, info, goal)
tween:Play()
tween.Completed:Wait()
door:SetAttribute("Open", not isOpen)
prompt.ActionText = if isOpen then "Open" else "Close"
prompt.Enabled = true
door:SetAttribute("Busy", false)
end)
The Busy attribute and the disabled prompt work together while the tween plays. The attribute stops a second handler from starting an overlapping tween, and disabling the prompt removes the key hint for everyone so nobody presses into a door that is already moving.
Because the door is shared, flipping ActionText on the server is the right call here. Every client should see "Close" once the door is open, which is the opposite of the keycard case later in this guide.
Disable the prompt and set a Busy attribute while a door tweens, then re-enable it when the tween completes. This blocks overlapping tweens from two players and keeps every client on the same door state.
Wiring A Pickup That Cannot Be Claimed Twice
Pickups add a reward, and a reward is where double claims start to cost you. The pattern is to claim first, grant second, and roll the claim back if the grant fails.
local ServerScriptService = game:GetService("ServerScriptService")
local PromptGuard = require(ServerScriptService.PromptGuard)
local Inventory = require(ServerScriptService.Inventory)
local pickup = script.Parent
local prompt = pickup.ProximityPrompt
PromptGuard.bind(prompt, 1, function(player)
if pickup:GetAttribute("Claimed") then return end
pickup:SetAttribute("Claimed", true)
prompt.Enabled = false
local itemId = pickup:GetAttribute("ItemId")
local granted = Inventory.grant(player, itemId, 1)
if not granted then
pickup:SetAttribute("Claimed", false)
prompt.Enabled = true
return
end
pickup:Destroy()
end)
Luau runs one handler at a time, so the gap that matters is any yield inside the grant, such as a DataStore write or a call to another service. If the Claimed flag were set after that yield, a second player's trigger could run inside the gap and receive the same item.
Inventory.grant stands in for whatever your own inventory module exposes, and the Roblox inventory systems guide covers how to build one that returns a clear success value. Destroying the pickup also destroys its prompt, which disconnects the guard's connections without any extra cleanup.
Mark a pickup claimed before granting the item, and roll back if the grant fails. If the grant yields, another player's trigger can run in that gap and claim the same item twice.
Wiring A Keycard Gate
A keycard gate adds an ownership requirement, and with it a messaging problem. The player without the card needs to hear why the gate stayed shut, but nobody else should see that message.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
local PromptGuard = require(ServerScriptService.PromptGuard)
local Inventory = require(ServerScriptService.Inventory)
local DeniedFeedback = ReplicatedStorage.Remotes.PromptDenied
local gate = workspace.Gates.LabGate
local prompt = gate.Reader.ProximityPrompt
PromptGuard.bind(prompt, 1, function(player)
if gate:GetAttribute("Open") then return end
local required = gate:GetAttribute("RequiredClearance")
if Inventory.highestClearance(player) < required then
DeniedFeedback:FireClient(player, "Clearance " .. required .. " required")
return
end
gate:SetAttribute("Open", true)
prompt.Enabled = false
gate.Barrier.CanCollide = false
gate.Barrier.Transparency = 0.8
task.delay(4, function()
gate.Barrier.CanCollide = true
gate.Barrier.Transparency = 0
gate:SetAttribute("Open", false)
prompt.Enabled = true
end)
end)
The clearance check reads the server's inventory record rather than looking for a Tool named Keycard in the player's Backpack. Tools are visible, movable and easy to confuse across renames, whereas a clearance value in your server data has exactly one writer.
The denial goes through FireClient to the one player who asked. Setting ObjectText to "Clearance 3 required" on the server would instead replicate to every client in range, and the next player with a valid card would see a gate that appears to reject them.
Per-player text belongs on the client. Anything you set on a prompt from the server is shared state. Use FireClient for denials, and set personalized ActionText from a LocalScript, where the change stays on that one machine.
If you want players without clearance to see a locked state before they press anything, a LocalScript can change ActionText to "Locked" on their client only. Of course, that is purely cosmetic, and the server check above still decides whether the barrier moves.
Building The Key-Press GUI On Top
The custom key-press GUIs developers ask for sit on top of this same server path. Set the prompt's Style to Custom, then listen for ProximityPromptService.PromptShown in a LocalScript to build your own BillboardGui and PromptHidden to tear it down.
Some useful client hooks for a custom prompt include:
- PromptShown. Fires with the prompt and the input type, so one handler can show a key cap on keyboard, a button glyph on gamepad, and a tap target on touch. The mobile touch controls guide covers sizing those touch targets so thumbs can actually hit them.
- PromptButtonHoldBegan and PromptButtonHoldEnded. Drive your own hold ring with these instead of the default one. Remember to reset the ring on HoldEnded so an abandoned hold does not stay half-filled.
- InputHoldBegin and InputHoldEnd. Call these from your own button so a clickable custom GUI feeds the same input pipeline as the key press.
Note that a custom style changes only presentation, so Triggered still reaches the server through the same route and PromptGuard needs no changes. The Roblox UI systems guide covers the BillboardGui scaling and theming side in depth.
Testing The Guard Before You Ship
A guard you have not watched reject something is a guard you are trusting on faith. Fortunately, Studio lets you reproduce each failure without any exploit tooling.
Here's a list of the tests worth running before release:
- Range. Start a Play test, switch to the client, and raise the prompt's MaxActivationDistance to 200 from the client command bar. Trigger it from far away and confirm the server ignores it, since the server still reads its own value of 10.
- Hold. On the client, set HoldDuration to 0 on a prompt whose server value is 3, then press once. The server should see a trigger with no matching hold time and reject it.
- Cooldown. Add a temporary print inside the handler and press the key as fast as you can. The print count should track the cooldown, not your keystrokes.
- Double claims. Insert a temporary task.wait(1) inside Inventory.grant and run a two-player Team Test against one pickup. Exactly one player should receive the item.
- Feedback. Trigger the keycard gate without clearance while a second test player watches. Only the first player should see the denial message.
Once those pass, consider counting rejections per player instead of silently discarding them. A single failed range check is usually latency or a teleport, whereas dozens per minute is a pattern worth sending to the review queue described in our Roblox moderation systems guide.
Change MaxActivationDistance or HoldDuration in the client command bar during a Studio test, then trigger the prompt. The server still reads its own values, so the guard should reject the trigger.
Where To Go Next
Every interactive object in your place now follows one path: the prompt fires, PromptGuard checks range, hold and cooldown, and the handler protects its own state before it yields. Doors, pickups and keycard gates differ only in that last step, which keeps new features small and keeps the trust boundary in one file.
If you are deciding where modules like this belong in a larger codebase, our Roblox server architecture guide covers service layout and startup order. You can also browse the full set of Roblox and game development guides for the systems that sit on either side of an interaction.
If you're wiring interaction across a large map and want a second set of eyes on the trust boundary, the team behind simplified.media builds and reviews production Roblox systems. Reach out through our game development services — we'll walk your prompts, name the checks that are missing, and leave you with a validation module that fits your codebase.


