Creating a request to pair system?

Hello, Im trying to create a system where you can request other players to pair through proximity prompts. This type of system can bee seen in lots of co-op themed games such as Altitorture & many other two player obbies. The thing that im trying to do, is optimize my code and make it as easy as possible.
I’ve tried coding such system before, but it ended up being a total mess. I had like 10+ Remote Events going in and out for 1 system, which obviously isn’t the way. I need help with the algorithm and understanding better its realization.

There are factors which I want to take into consideration:

  • Make sure the proximity prompt is placed in everyone, except on the client itself.
  • Once triggered, the player whose proximity had been triggered, gets a GUI pop-up with 2 options: Accept, Decline.
    If Accept is hit, they get paired up. Otherwise, they reject their request.
  • Once a player requests another player to pair up, the proximity prompt on both of them will get disabled for EVERYONE until the request has timed out or the requested player hits decline.
  • A way to determine whether a player is paired up or not.

Its a bit of a complicated system to work with, so if anyone has some feedbacks or tips on how I can put it to realization, that would be highly appreciated! Anyway, thanks.

1 Like

I won’t write the system for you, but here’s a structure:

  • Player 1 clicks player prompt.
  • Server receives player and the target player (ProximityPrompt.Triggered) (Player 2) and attempts to get a response from Player 2 (either using a RemoteFunction, or two RemoteEvents not recommended to invoke clients using RemoteFunctions). UI for Player 2 pops up with request, and listens for one-time clicks on either accept or deny buttons. Returns the result/fires back to server.
  • Server receives request and sets attributes for the players accordingly, which can determine whether they are eligible for pairing or not. Prompt is controlled by ProximityPrompt.Enabled, incorporate into this structure where necessary.