Cross server matchmaking in roblox studio. — Transcript
Full transcript
- 0:00hey there fellow developers today we
- 0:02will be diving into the cross server
- 0:04matchmaking system in Roblox
- 0:06specifically the one versus one
- 0:08matchmaking where two similar level
- 0:10players will be matched up and
- 0:12teleported to a reserved server I'll do
- 0:14my best to explain how the system works
- 0:17however having a basic understanding of
- 0:19Roblox scripting is necessary to grasp
- 0:21its functionality you need to understand
- 0:24how memory store service messaging
- 0:26service and teleport service work so
- 0:29let's see how this system will work
- 0:31think of the memory store as a folder
- 0:34this folder will contain all the cues
- 0:36the cues which is a table data or also
- 0:39works like folders and name of the
- 0:41folder is the key that will help us to
- 0:42find the queue in the memory
- 0:44service now in the queue we will save
- 0:47the data of players who are in the queue
- 0:49as a
- 0:51table that table will contain the
- 0:53player's user
- 0:57ID and their level which will will be
- 1:00used for player
- 1:02matching now when a player joins the
- 1:04queue there are three possible scenarios
- 1:07the first scenario is when the game
- 1:09fails to retrieve the queue from the
- 1:11memory store although the chances are
- 1:13low it's not zero in this case we will
- 1:16just tell the player to try again later
- 1:19the second scenario occurs when the game
- 1:21successfully retrieves data but there's
- 1:23no actual queue stored in memory this
- 1:26happens because the data stored in the
- 1:27memory store service isn't permanent in
- 1:29will vanish upon reaching the maximum
- 1:32lifetime however there's no need to
- 1:34worry as every time a player joins or
- 1:36leaves the queue it resets the data's
- 1:38maximum lifetime data stored in the
- 1:41memory service can last up to 45 days
- 1:44essentially if no player interacts with
- 1:46your game until the lifetime limit is
- 1:48reached the queue will be deleted due to
- 1:50lack of activity it's kind of sad
- 1:53because no one's playing your game in
- 1:55these cases we simply create the queue
- 1:57and insert the player's data into it
- 2:15the third scenario occurs when the game
- 2:17successfully retrieves data from the
- 2:19memory store and finds the queue then
- 2:22the game will iterate through the data
- 2:24of every player in the queue to find a
- 2:25player with a matching
- 2:28level
- 2:32if it doesn't find a match it simply
- 2:34inserts the new player data into the
- 2:38queue if it finds a player with a
- 2:41matching level it first removes the data
- 2:43of the matching
- 2:46player then using the teleport Services
- 2:49Reserve server function it generates a
- 2:51reserve server and returns a access code
- 2:54now we'll create a table of data using
- 2:57both players user IDs and access codes
- 3:14finally using the messaging service we
- 3:16instruct all servers in the game to
- 3:18check if either of those players are in
- 3:20them if found they are teleported to the
- 3:22reserve server using the access code
- 3:25however there's still a problem is the
- 3:27messaging service doesn't support
- 3:29sending table type data directly hence
- 3:32we need to use the HD deep Services Json
- 3:34encode function to encode the
- 3:37table now that we have a basic
- 3:40understanding of how it will work let's
- 3:42proceed to creating the system firstly
- 3:45we need to publish the
- 3:58game
- 4:06after that we need to add another place
- 4:07where players will be teleported to do
- 4:10this go to the asset
- 4:13tab select
- 4:17places then right click and add a new
- 4:28place now add a script to the server
- 4:31script
- 4:36service firstly let's retrieve all the
- 4:38services and store them in a local
- 4:58variable
- 5:01now let's create a sorted map in the
- 5:03memory service and name it Q
- 5:09store this sorted map will work like the
- 5:11folder that holds all the other Q
- 5:13folders such as one versus one 2 versus
- 5:162 4 versus 4 Etc now let's add three
- 5:20remote events in the replicated storage
- 5:22and name them join leave and
- 5:25teleport also create three variables for
- 5:28each of them
- 5:36now let's create a function that detects
- 5:38when a player joins the game it will
- 5:41create a folder called leader stats and
- 5:43insert a number value called
- 5:46level while naming the folder leader
- 5:48stats isn't necessary for the
- 5:50matchmaking to work it allows us to see
- 5:52the level in
- 5:56game let's give it a go
- 6:02and now we can see the level on the
- 6:03right top
- 6:06Corner let's create the buttons to join
- 6:08and lead the
- 6:24queue next we'll insert a local script
- 6:27and create variables for the events
- 6:46we'll then detect when the player
- 6:47presses the join button and fire the
- 6:49join remote event additionally we'll
- 6:52make the join button invisible and the
- 6:54leave button visible now let's go back
- 6:56to the server script and detect when the
- 6:58join remote event fires connecting it to
- 7:01a function firstly we'll obtain the
- 7:03player's user ID and player
- 7:08level next we retrieve the queue from
- 7:10the memory store we'll enclose it in a
- 7:12PE call just in case something goes
- 7:15wrong and we don't want the whole script
- 7:16to break the P call function returns two
- 7:19values success indicating if it worked
- 7:22fine and result which Returns the Quee
- 7:25when success is true if success is false
- 7:28it Returns the errors that caused the
- 7:30failure Now using the get async function
- 7:33we will obtain the Q which takes the key
- 7:35as its parameter in my case the key is 1
- 7:38V1 as I mentioned earlier regarding the
- 7:41possible scenarios of retrieving the que
- 7:43from the memory store let's first handle
- 7:46the situation where we successfully
- 7:47retrieved the queue but there isn't any
- 7:49actual data this means the success value
- 7:52is true but result is nil in this case
- 7:55we will create a queue and upload it to
- 7:57the memory store let's create a
- 8:01table and inside that table we will
- 8:03create another table with the player's
- 8:05user ID as its Index this will help us
- 8:08find the players data easily later on
- 8:10when the players leave the queue now
- 8:13inside that table we will add the user
- 8:15ID in the level however there is another
- 8:18problem since we use the player's user
- 8:20ID as an index which is a number some
- 8:22players might get prioritized over
- 8:24others for example if a player with user
- 8:27ID 1 mil10 is in the queue and a new
- 8:30player joins with user ID 1,9 keeping
- 8:33the index as a number would put the new
- 8:35player in front of the previous player
- 8:37this is unfair and might cause longer
- 8:39wait times for some people to avoid this
- 8:42we will make the index a strain now
- 8:45let's upload the new queue to the memory
- 8:47store make sure to enclose this function
- 8:49in a p call the set a sync function
- 8:52takes three parameters the key the value
- 8:55and the duration I will create a local
- 8:57variable for the duration since we need
- 8:59to use it more than once I'll set the
- 9:02duration to 24 hours or
- 9:0486,400
- 9:05seconds now let's print out the results
- 9:08to make it easier to debug in the
- 9:21future now let's handle the second
- 9:24scenario where we successfully retrieved
- 9:26the queue and there is data meaning
- 9:28success is true true and result isn't n
- 9:31in this case we will iterate through the
- 9:33queue to find a player with a similar
- 9:40level when we find a matched player we
- 9:43will remove that player's data from the
- 9:45queue and upload it back to the memory
- 9:53store we'll save the player's data table
- 9:56in a local variable and break through
- 9:58the loop
- 10:02after the loop we will check if the
- 10:03match player variable is nil or not if
- 10:06not nil that means a match was found and
- 10:09we will create a table data with the
- 10:11user IDs of the two players and the
- 10:12reserve server code using the teleport
- 10:15Services Reserve server function this
- 10:17function takes the place's ID as its
- 10:19parameter to get the place ID go to the
- 10:22assets tab select places right click on
- 10:25the place and then copy the ID to the
- 10:28clipboard
- 10:36next we need to encode this data table
- 10:38using the HTT Services Json encode
- 10:41function after that we are ready to
- 10:43publish this message using the messaging
- 10:46service we will also enclose this in a p
- 10:49call the messaging services publish
- 10:51async function takes two parameters the
- 10:54topic which works like a key in the
- 10:58message
- 11:02following that we will print out the
- 11:15results now let's handle the scenario
- 11:18where we failed to retrieve the
- 11:22queue let's first create a text label
- 11:25that will inform the player that
- 11:26something went wrong and to try again
- 11:30we will make it invisible after that go
- 11:33back to the local script instead of
- 11:35directly making the leave button visible
- 11:37we will wait for the server's response
- 11:40let's create a local variable that will
- 11:42hold the response event and assign it to
- 11:44the join remote event function we will
- 11:46receive a message from the server after
- 11:49receiving the response we need to
- 11:50disconnect the function because it is
- 11:52not needed anymore I forgot to show it
- 11:54in the video but this is how it is
- 11:57done following that we will check what
- 12:01the message is if it is an error we will
- 12:03make the error text label visible wait
- 12:05for one second then make the text label
- 12:08invisible again and make the join button
- 12:15visible If the message is a success we
- 12:18will wait for a bit and then make the
- 12:20leave button visible now go back to the
- 12:23server script in the if statements where
- 12:25success is true we will respond with a
- 12:27success message and error message where
- 12:29success is
- 12:36false I forgot to mention the part where
- 12:39the match player isn't found in this
- 12:41case we can simply insert the player
- 12:43into the queue and upload it back to the
- 12:45memory
- 12:57store
- 13:21now we will teleport the players first
- 13:24we will get the message from the
- 13:25messaging service and decode it
- 13:31after that we will create a Teleport
- 13:33option and set its Reserve server access
- 13:36code property to the reserve
- 13:40code following this we will Loop through
- 13:43every player in this server and check if
- 13:45their user ID is the same as either of
- 13:47the two players in the message if it is
- 13:49the same then using the teleport
- 13:51Services teleport async function we will
- 13:54teleport them to the reserve
- 13:57server
- 14:09if the teleport was successful we tell
- 14:12the client that it is being teleported
- 14:13by using the teleport remote event let's
- 14:16create a blur effect and turn it
- 14:23off after that the client will listen to
- 14:26the event and enable the blur effect
- 14:28let's also create a text
- 14:44label now for the leave button the
- 14:47client side code is exactly the same as
- 14:49the join button I'll just copy paste the
- 14:52code and change the
- 14:57variables
- 15:01now for the server script we will first
- 15:03retrieve the
- 15:13queue then using the player's ID as an
- 15:16index we will check if the player's data
- 15:18is in the queue if it is we will remove
- 15:21that data from the queue upload it back
- 15:23to the memory store and send a
- 15:27response
- 15:59now we will fire the leave event when a
- 16:01player leaves the game just in case a
- 16:03player joins the queue and leaves the
- 16:05game pathetically we will also remove
- 16:08players from the queue when the server
- 16:10is about to shut
- 16:14down finally our system is complete but
- 16:18before testing we need to do a few
- 16:19things first make the game
- 16:23public turn on HTTP requests and third
- 16:27party teleport now publish the game also
- 16:31let's go to world one and change the
- 16:32color of the base
- 16:54plate at last we can test our game
- 16:57however there is a problem problem
- 16:58because we can't use Roblox multi-
- 17:00instance to run multiple accounts on the
- 17:02same device and run this system for some
- 17:04reason if we try to do so only one
- 17:07account will get teleported but the
- 17:09other account will encounter error
- 17:11773 attempted to teleport to a place
- 17:14that is restricted so we need to use
- 17:17different devices for each account I
- 17:19will use my phone for the other account
- 17:20and give it a
- 17:27try
- 17:48as we can see it works if you are still
- 17:50concerned you can always test it
- 17:52yourself link is in the description we
- 17:55have finished our journey here today
- 17:57hopefully you have learn learned
- 17:58something from this video liking and
- 18:00subscribing are highly appreciated if
- 18:03you still have lingering questions about
- 18:05anything leave them in the comment
- 18:06section and I will try my best to answer
- 18:09peace out
About this transcript
This page contains the full transcript of Cross server matchmaking in roblox studio. by TextChanged , generated from the public captions YouTube serves with the video. The transcript has 2,102 words across 319 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.