How to teleport players to another game using local script

local counter = 5
local players = game:GetService("Players")
local tps = game:GetService("TeleportService")
local placeid = 11726871265
local tpoption ="TeleportOptions")

for i = counter, 0, -1 do
	script.Parent.Text="Teleporting You back in <font color=\"#FFC900\">"..i.." Sec </font>"
script.Parent.Text="Reserving Server"
local tpoption ="TeleportOptions")
tps:TeleportAsync(placeid, tpoption)

this is the code I tried to run but it came and error on teleporting but it worked on script, I wanted to work it on script, how could I

Hope you could Help, Thank you

1 Like

you should use a remote event however im afraid exploiters can spoof this with remotespy so try using a remote function

RemoteFunction | Roblox Creator Documentation (Not sure)
RemoteEvent | Roblox Creator Documentation (NOT RECOMMENDED)

Remote functions are used to send information back to the sender:

Client(s) -> Server -> Client(s);
Server -> Client(s) -> Server

They are susceptible to exploitation as much as RemoteEvents, which do not send information back to the sender:

Client(s) -> Server;
Server -> Client(s)

Instead, @Ma7adi805, I suggest validating player input in a way the server can check.

Maybe have the players stand in a region, or have them chat a phrase to confirm that they want to teleport to a different game?

1 Like

You need to fire a RemoteEvent to get your player teleported. You can use RemoteEvent:FireServer(), and on the 1st parameter of the server, the player is already there:


What’s the error code?

Unable to Cast value to objects

I cannot use onclient event there is only onserverevent

    -- teleport player

I got the same error, and that’s what I did

local event = game:GetService("ReplicatedStorage"):WaitForChild("Teleport")
local placeid = 11726871265
local tps = game:GetService("TeleportService")
	local tpoption ="TeleportOptions")
	tps:TeleportAsync(placeid,player, tpoption)

even though they are susceptible to exploitations too, most hackers dont know how to use remotefunction which is exactly why i suggest it.

1 Like

you should put your placeid in

What line

I did but I forgot to include the variable to the script, I will edit it

Line 8, Unable to cast value to objects

Then your error is when you’re trying to set the text, not the teleporting stuff right

no I am teleporting the player

Btw I used game.players:GetPlayers() to teleport and it worked, is it safe if I kept it like that

1 Like

is this line 8?

If you’re teleporting on the client yeah it’s safe

1 Like