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

How do I go about match making with reserved servers?

Asked by 5 years ago

Im trying to create a match system where once it begins, other players can't join. I've been looking for quite a while and there really isn't much info about using reserved servers for match making.

This is what I've gotten so far, but how would I create a new server once one starts.

~Local script

script.Parent.MouseButton1Click:connect(function()
game.ReplicatedStorage.Events.Teleport:FireServer()
end)

~Server side script

local TS = game:GetService("TeleportService")
local Players = game:GetService("Players")
local DSS = game:GetService("DataStoreService")
local DS = DSS:GetGlobalDataStore()


GameMode = fakeid24343

-- Get the saved code
game.ReplicatedStorage.Events.Teleport.OnServerEvent:connect(function(plr)
local code = DS:GetAsync("Test02")
if type(code) ~= "string" then -- None saved, create one
    code = TS:ReserveServer(GameMode)
    DS:SetAsync("Test02",code)
end

game.ServerStorage.PlayerStats:WaitForChild(plr.Name).GameStats.ServerId.Value = code
TS:TeleportToPrivateServer(GameMode,code,{plr})
end)

0
U can’t get player’s from a script send it with the fireserver MaxDev_BE 55 — 5y
0
U aren’t using the local players so delete it MaxDev_BE 55 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

So put this in the local script

local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
game.ReplicatedStorage.Events.Teleport:FireServer(plr)
end)
0
Player argument is automatically passed when using remote events/functions. The part I need help with is creating a new reserved server when one is full. ICosmicReaver 32 — 5y
Ad

Answer this question