Need a method to prevent multiple players from performing the same action at the same time

I’m working on a door system where players press E to open/close doors (Basically like Flee The Facility). The doors are controlled by a Server Script with a RemoteEvent, and there’s a progress bar UI on the client showing the opening animation.

I initially tried using a BoolValue in the door model locked for server-side debounce, so multiple players could not open the door simultaneously. That approach didn’t work as intended, and the local progress bar still appears for multiple players pressing E at the same time

Server Script:

  • Stored in each door model.
  • Tracks the current door state (Opened/Closed).
  • Handles door tweening and collision changes.
  • Listens to a RemoteEvent from the client (DoorOpen) and only operates if the door isn’t locked.
  • Fires a DoorTweenFinished event after the tween finishes for client-side feedback.

Client Script (LocalScript):

  • Listens to user input (E key).
  • Finds the nearest door within 5 studs.
  • Fires the server RemoteEvent (DoorOpen) with the desired action.
  • Animates the GUI progress bar based on server confirmation (previous attempts just showed it immediately, which caused multiple players to see a different bar even when the door was busy).

I was hoping anyone had a solution to this issue, I would really appreciate code examples or approaches!
If you need any more info please just ask.

local editing: {[BasePart]: boolean = {}

Door.OnServerEvent:Connect(function(plr, door: BasePart, state: boolean)
    if typeof(door) ~= "Instance" then return end
    if not door:IsDescendantOf(workspace.Doors) then return end
    if editing[door] then return end

    editing[door] = true
    --// Open door or wtv
    editing[door] = nil
end)

whats so hard about this?

I’ve tried doing a similar method but the GUI still appears for other players. It doesn’t prevent the local input from triggering the bar.

You want “first” player to open the door?

i think you need get “first” player clicked, whenever it clicked by first player, try make it disables prompt E include visible for all of players except “first player”

oh by the way, my grammar are terrible.