How would I send the gamemode when teleporting

So im currently making a queue system similar to doors, I have 2 gamemodes, Normal mode and Endless mode. They all teleport to one place. How would I go about sending data about what gamemode they have chosen. I have read about the teleport service but it just doesnt seem to make any sense for me. Any code samples or explained answers would really help. Thank you for reading

1 Like

TeleportOptions maybe useful

5 Likes

Do you know how script the queue system?

3 Likes

Okay so when I teleport them to the actual game, would I use the teleport async with the teleport options such as {Gamemode = “Normal”}, then use Get local teleport data. Problem is if the client receives it I need the server to know what gamemode it is not the client. Thank you for your response.

3 Likes

Yeah so essentially queue is done, I have a table of players ready to be teleported when the queue is over. Only problem is transferring data from server to server via teleport

3 Likes

I found in a video this script that works like a bindable event but without it.

Main Game:

local TeleportService = game:GetService("TeleportService")


local placeId = writethere

game.Players.PlayerAdded:Connect(function(player)
local teleportOptions = Instance.new("TeleportOptions")
teleportOptions.ShouldReserveServer = true

local teleportData = {
Test = "ok"
Number = 3,
}
teleportOptions:SetTeleportData(teleportData)

TeleportService:TeleportAsync(placeId, {player}, teleportOptions)

end)

Place to teleport



game.Players.PlayerAdded:Connect(function(player)
local joinData = player:GetJoinData()
local teleportData = joinData.TeleportData

local test = teleportData.Test
local number = teleportData.Number

print(test)
print(number)

end)
2 Likes

credit of the video: BrawlDev - Teleport Service

1 Like

that’s correct, just make sure that they are both local scripts.

1 Like

Local scripts? In the video are scripts.

1 Like

No, they must be local scripts, you can’t send data to the server.

1 Like

Thank you very much ill leave it as the solution much appreciated

1 Like

is there any way to send data to the server, it will kinda unrealistic to have every client send the gamemode data

2 Likes

use remote events.


local joinData = player:GetJoinData()
local teleportData = joinData.TeleportData

local test = teleportData.Test
local number = teleportData.Number

remoteEvent:FireServer(test, number)

1 Like

Ok thank you, I thought it would be more prone to hackers but itll do cheers

2 Likes

no problem, just remember always put your if statements on the server, since hackers can’t access server scripts :+1:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.