How do i make a place lock, story games

Hello! I want to make it so that once a group of players gets teleported into a new place, no one else can join that server. I’ve been noticing this issue with my story game that once players get teleported, if there is more than 2 games running once i tp them into the other place, they just join the already running server. Is there any way to like “lock” a server so no one else can join?

To keep players from being teleported to an existing server use TeleportService:ReserveServer() and then TeleportService:TeleportToPrivateServer()

If you still run into issues (which you shouldn’t) you could set up a simple server script that goes something like this:

game.Players.PlayerAdded:Connect(function(plr)
     plr:Kick("Game has already started")
end)
2 Likes

Omg thank you so much! If this works like wow I may put you in credits because this has been such a big issue XD

So like what would I put, like I woudl type for i,v in pairs (playersorwhatever) v:ReserveServer() TeleprotService:TeleportToPrivateServer(v) ?

I didn’t really do much, I had just been pondering TPService stuff before and looked into it a bit, all of the info is here though:
https://developer.roblox.com/en-us/api-reference/class/TeleportService

1 Like

Ok- yeah lol it does help though. So I would jsut make a list of the players wherever or whoever i want to teleprot them i like type what peramiters around the player and like how do I “make” and teleport all those players to that server? Sorry if that was a bit confusing of a question XD

You would run ReserveServer once to get the private server access code, and then you’d get the group of players as you would for TeleportPartyAsync() and you’d instead use TeleportToPrivateServer() with the one extra value for the access code. Here is the DevHub page:
https://developer.roblox.com/en-us/api-reference/function/TeleportService/TeleportToPrivateServer

You would create a table like this:

local playersToTP = {}

Then you could use a for loop or anything like that to add the playerObjects to the table, like this:

playersToTP[0] = game.Players["BMWLux]

Then you would get the access code like so:

local accessCode = TPS:ReserveServer([placeID])

Then do:

TPS:TeleportToPrivateServer([placeID], accessCode, playersToTP) --There are also optional paramters you can add if thats part of your game
1 Like

I can’t figure out why my story script wont work, i have all services on and 0 errors. Here is my script.

					local playersToTP = {}
					playersToTP[0] = game.Players:FindFirstChild(v.Name)
					local TPS = game:GetService("TeleportService")
					local placeID = 8255221208
					local accessCode = TPS:ReserveServer(placeID)
					TPS:TeleportToPrivateServer(placeID, accessCode, playersToTP) --There are also optional param
				end

I may have messed up there, I’m too used to other languages, I don’t think the first index is 0 in Lua, I think it’s 1, so set playersToTP[0] to playersToTP[1], sorry about that :slight_smile:

1 Like

Damn that was a FAST response! :smiley: Ok ill test it out (:

Ngl I kinda luv u XD, dude this helps so much, you can test my beta story game once it comes out and get contributor rank in my group if u like lol, once my game gets big i hope you get recognition for what you have done xD