Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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:

0
use code block User#34743 0 — 4y
0
? KingIce1310 23 — 4y
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) SteamG00B 1633 — 4y

1 answer

Log in to vote
0
Answered by
bnxDJ 57
4 years ago

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.

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? KingIce1310 23 — 4y
0
also where should i put the script and what kind of script should i put the code in? KingIce1310 23 — 4y
Ad

Answer this question