Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make a matchmaking system for my MOBA game?

Basically I want it like this.

The player joins the matchmaking place (cause they were teleported from the lobby to this place)

After 70 seconds, all the people in that server are teleported to another place (the map). I want it to be a private server cause I dont want people joining mid-game.

After the game is finished (I can script this myself), they are teleported back to the lobby place.

I tried this yesterday with this script:

~~~~~~~~~~~~~~~~~
local TS = game:GetService("TeleportService")

local Players = game:GetService("Players")

local PlaceId = 5002451166

local code = TS:ReserveServer(game.PlaceId) -- Returns a code

local players = Players:GetPlayers() -- Get a list of all players


game.Players.PlayerAdded:Connect(function(player)

wait(7)

TS:TeleportToPrivateServer(game.PlaceId,code,players) -- Actually teleport the players

~~~~~~~~~~~~~~~~~



But it didn't work. Please help! c:

3 comments

0

use code block

0

?

0

https://scriptinghelpers.org/help/how-post-good-questions-answers I recommend you read the whole thing, but for now, just scroll down until you see the section about formatting (bottom of the page)

1 answer

You are trying to teleport them to the same place without using the PlaceId variable you set

Just note that this is only the teleporting part and not when it teleports all players after 70 seconds.

local TS = game:GetService("TeleportService")

local Players = game:GetService("Players")

local PlaceId = 5002451166

local code = TS:ReserveServer(PlaceId) -- Returns a code (used to be game.PlaceId not the variable) This would have to be inside the loop otherwise it would use the same code and other players would be teleported to the same server which has started the game already.

local players = Players:GetPlayers() -- Get a list of all players


TS:TeleportToPrivateServer(game.PlaceId,code,players) -- Actually teleport the players

If you add game.Players.PlayerAdded:Connect(function(player) then everytime a new player joins it would start the script again and make it run.

2 comments

0

okay so if i add game.Players.PlayerAdded:Connect(function(player) at the start before all the variables and a wait function after the last variable will it wait 70 seconds after a player joins, then teleport all the players?

0

also where should i put the script and what kind of script should i put the code in?

This discussion is preserved as it was. New answers, comments, and votes are closed.