How to send datas for each person that'll be teleported [EDITED]

Hello, in my game I have a teleport system which allows you to 1v1 on a private server too. It used to work, I didn’t change anything on TeleportScript but suddently, it stopped working. All PlaceId’s are same and I checked. Here’s what happens:

  • I tried with 2,3,4,5 player servers and they just don’t teleport, I have some prints when teleport starts to happen and they get executed correctly.
  • In studio, as always, it says HTTP 403 (Forbidden) which shows that server took the request.

Anyone has ideas for this? Does same thing happen to you?

Script:

local TeleportService = game:GetService("TeleportService")
local RepStorage = game:GetService("ReplicatedStorage")
local TeleportDirecter = RepStorage.BindableEvents.TeleportDirecter

TeleportDirecter.Event:Connect(function(creator, plr2)
	local reservedServerCode = TeleportService:ReserveServer(4830564901)
	TeleportService:TeleportToPrivateServer(4830564901, reservedServerCode, creator,"WaitingSpawn",true)
	TeleportService:TeleportToPrivateServer(4830564901, reservedServerCode, plr2,"WaitingSpawn",false)
end)

Note: I added the false and true values recently it if’s causing the problem. Also seperating teleports may be causing it too because it was on the same line before.

This true or false’s are sender and accepters.

Update: It started to work when I revert it to:

local TeleportService = game:GetService("TeleportService")
local RepStorage = game:GetService("ReplicatedStorage")
local TeleportDirecter = RepStorage.BindableEvents.TeleportDirecter

TeleportDirecter.Event:Connect(function(creator, plr2)
	local players = {creator,plr2}
	local reservedServerCode = TeleportService:ReserveServer(4830564901)
	TeleportService:TeleportToPrivateServer(4830564901, reservedServerCode,players)
end)

But I definetely need to send different datas with players.

3 Likes

You cannot teleport in studio, so that’s why it threw an error.

To send data a reccomend you to use datastores. Basically places in the same universe will have access t the same datastore. To retrieve the data, just do it like you do it in the original place, no extra code needed. In addition, this is probably the safest way to transfer info, because the other way is exploitable.

1 Like

I know and I mentioned this on post.

I only need to send something that indicates who has sent the request (creator) and who received (plr2). I can’t use datastore with these.

I think you have to wait before firing another teleport command. You should utilize TeleportPartyAsync.

Still not working.

local TeleportService = game:GetService("TeleportService")
local RepStorage = game:GetService("ReplicatedStorage")
local TeleportDirecter = RepStorage.BindableEvents.TeleportDirecter

TeleportDirecter.Event:Connect(function(creator, plr2)
	local players = {creator,plr2}
	local reservedServerCode = TeleportService:ReserveServer(4830564901)
	TeleportService:TeleportPartyAsync(4830564901, creator, {true})
	wait()
	TeleportService:TeleportPartyAsync(4830564901, plr2, {false})
end)

TeleportPartyAsync takes an array of players. In your code above, you already define this as players. You do not want to use TeleportPartyAsync if you’re teleporting to a reserved server as that’s not what it’s made for; you’ll need to use TeleportToPrivateServer instead (which you were already using initially), which also takes an array of players.

The reason your separation broke is because, like I said, both methods take an array of players, and will error when given individual players instead. You can fix this by passing an array with a single player in it, eg. {plr2} and {creator}.

If you want to send players together, you’ll have to give them the same teleport data. You can’t separate their data unless you separate the teleport methods. If you seriously need to give them different data, separate it like you had in your initial code script, except pass an array with one player (eg. {plr2} NOT plr2}

local TeleportService = game:GetService("TeleportService")
local RepStorage = game:GetService("ReplicatedStorage")
local TeleportDirecter = RepStorage.BindableEvents.TeleportDirecter

TeleportDirecter.Event:Connect(function(creator, plr2)
	local reservedServerCode = TeleportService:ReserveServer(4830564901)
	TeleportService:TeleportToPrivateServer(4830564901, reservedServerCode, {creator},"WaitingSpawn",true)
	TeleportService:TeleportToPrivateServer(4830564901, reservedServerCode, {plr2},"WaitingSpawn",false)
end)

If this is a server script, remember that you can use Player:GetJoinData() to get the teleport data. If sent via a client script, use LocalPlayerArrivedFromTeleport (or GetLocalPlayerTeleportData)

I would recommend not using datastores for this purpose unless absolutely necessary. TeleportData is already built-in to the teleport methods and it wouldn’t make sense to use datastores as opposed to TeleportData.

TeleportData is not exploitable if it is sent on the server.

You can only retrieve teleport data from a local script, and sent it to the server via remote event. Therefore, there is absolutely no way of checking if there is something wrong. Keep in mind that all info from the client should not be trusted. As mentioned in this thread: Exploiting Explained

In addition, on the roblox developer hub:

GetJoinData and TeleportData

This function can only be used to fetch teleportData on the server, to retrieve it on the client use"

Really? I’m using a teleport method & teleport data and :GetJoinData on the server and it works perfectly fine. It passes teleport data server to server, and is interpreted appropriately. If the wiki says that it can only be retrieved on the client that should be updated.

GetJoinData’s page explicitly says:

This function can only be used to fetch teleportData on the server

and

Despite this, it is still appropriate for the secure transmission of immutable data (data that can not be changed).

I never said anything about trusting the client with the game logic, which makes that point completely irrelevant to anything I said here. Consider re-reading my post.

1 Like

I’d recommend teleporting the player and using the teleportData parameter in TeleportToPrivateServer. Then you can run TeleportService:GetLocalPlayerTeleportData() on the client when you arrive.

I’ve read every solutions and,
@Thundermaker300 Are arrays just strings with 1 value in them?

By the way thanks for responding, I’ve learnt lots of things about TeleportService.

Arrays are essentially “lists” of any form of data. In this case it’s a list of players to teleport. It’s not necessarily just one item (in your example, you made {creator,plr2} which is an array; {plr2} is also an array). TeleportToPrivateServer requires that the players being teleported is an array, even if it’s only one player.

1 Like