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
TS:TeleportToPrivateServer(game.placeID,code,players) -- Actually teleport the players
-------I am testing this in a real game, not in roblox studio by the way.----
So this script is meant to run when a player joins the "lobby" Place in my Game. It should wait 10 seconds, then teleport the players in that lobby server to the map. (the map is a seperate Place in my Game, btw)
local TS = game:GetService("TeleportService") local Players = game:GetService("Players") local code = TS:ReserveServer(game.PlaceId) local players = Players:GetPlayers() TS:TeleportToPrivateServer(game.PlaceId,code,players)
I compared it with your code and your code should be right cuz it works for me .-. Maybe its just because you wrote "PlaceID" instead of "PlaceId" ?
Edit (cuz u wanted it):
local TS = game:GetService("TeleportService") local Players = game:GetService("Players") local tid = YOURPLACEID local code = TS:ReserveServer(tid) local players = Players:GetPlayers() TS:TeleportToPrivateServer(tid,code,players)
Second edit:
game.Players.PlayerAdded:connect(function(plr) wait(10) --Cuz you wanted a wait time local TS = game:GetService("TeleportService") local tid = YOURPLACEID local code = TS:ReserveServer(tid) TS:TeleportToPrivateServer(tid,code,plr) end)
Third edit:
Ok for everyone who wants to know what the issue was: He used a LocalScript in the server xD Just replace the localscript with a normal script :D I hope this can help some people You guys just can read all comments under all answers here .-.
is this where i should put the playeradded func?
local players = Players:GetPlayers()
Players.PlayerAdded:Connect(function(player)
local TS = game:GetService("TeleportService")
local Players = game:GetService("Players")
local tid = 5002451166
local code = TS:ReserveServer(tid)
wait(10) TS:TeleportToPrivateServer(tid,code,players)