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

bruh back with another question!!!! why won't this script teleport teh players to a private server?

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)

17 comments

0

What is "game.5002451166" for?

0

its the id of the game that i want the players to be teleported to.

0

try to replace it with "5002451166"

0

aight thx

0

yeah that didnt work

0

u said u are testing ingame, press f9 (output key) what is in it?

0

btw game.placeId wont teleport you

0

it said no messages were found

0

what will teleport me to that place's id?

0

just replace "game.placeID" with "placeID"

0

aight

0

look: In the "placeID" variable you put the placeId where u want to teleport, then u write "TS:ReserveServer(placeID)" and TS:TeleportToPrivateServer(placeID,code,players)

0

ohh dang I understand something wrong sryyyyy

0

Let me write an answer xD

0

okie

0

u done? thx :)

0

u done? thx :)

2 answers

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 .-.

13 comments

0

ok but how do i define the id of the place i want to be teleported to? cuz on ur script theres no place to define it

0

wait let me edit something :D

0

yeah its still not working

0

thats strange

0

i added a wait(5) before the TS:TeleportToPrivateServer(tid,code,players)

0

but its still not workingggggg

0

Wait when does ur script run?

0

?

0

Cuz maybe u just dont get teleported cuz u are not in the game .-

0

maybe u can just add a longer wait time?

0

but i already added a wait(5) function? maybe i should add a playeradded function as well. where should i put it ?

0

at the start

0

aight

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)

25 comments

0

wait let me edit the script again

0

ok

0

na still not working :C

0

wth

0

Thats verrrrrryy strangggge

0

ikr

0

Ok first of all: Is your script a server script? + is it enabled? + where did you put it?

0

its a localscript in serverscriptservice and its not disabled

0

LocalScripts wont work in the server...

0

Use a normal script :D

0

ight changed it to a normal script - is it in the right place tho?

0

yes

0

okie its still not working thooooooooooooo

0

And remember that LocalScripts will only work in : StarterPack,StarterPlayerScripts,StarterGui

0

wait it must work now

0

wait it must work now

0

You said u are testing ingame: Did u leave the game and published the update?

0

ok but do you have any other solutions? I tried putting the script in workspace instead of serverscriptservice but that didnt work

0

yeah i left the game and pubished the update

0

Scripts can work in serverscriptservice

0

are you sure that there are 100000001% no errors?

0

yes i am 1000000000000000000000000000000000000000000000001 percent sure m8

0

hmmmmm

0

Strange.. its working fine for me, I guess I cant help u

0

ok rip

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