Getting teleport data won't work

I’m trying to give people a gear if their teleport data said they do have it, but for some reason the teleport data won’t get sent.
Script where I send all players:

player.IsBeingTeleported.Value = true
            
local teleportOptions = Instance.new("TeleportOptions")
local teleportData = {
  speedCoil = player.Gears.SpeedCoil.Value,
}
print(teleportData.speedCoil)
            
teleportOptions:SetTeleportData(teleportData)
            
remotes.ClientStatus:FireClient(player, "teleportUI", ReplicatedStorage.RLGLTeleport)
wait(1)
TeleportService:TeleportToPrivateServer(ChosenGamemode.Value, serverID, {player}, teleportOptions, ReplicatedStorage.RLGLTeleport)

Yes, it does print true at the print.

Script where I receive the player data in other place:

local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local approvedPlaceIds = {ids here}

local function isPlaceIdApproved(placeId)
    for _, id in pairs(approvedPlaceIds) do
        if id == placeId then
            return true
        end
    end
    return false
end

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

    if isPlaceIdApproved(joinData.SourcePlaceId) then
        
        print("AAAAAA")
        
        local teleportData = joinData.TeleportData
        if teleportData then
            print("e")
            if teleportData.speedCoil == true then
                print("yessir")
                local speedCoil = ServerStorage["Speed Coil"]:Clone()
                speedCoil.Parent = player.Backpack
                
            end
        end
    end
end)

All it prints is the “AAAAAA”, but there it stops. Does it not send the data or what’s the problem?

1 Like

“joinData.TeleportData” must be nil for the following conditional statement to not evaluate as true. Also instead of checking if a user teleported like this you should employ the LocalPlayerArrivedFromTeleport event from the teleport service.

https://developer.roblox.com/en-us/api-reference/event/TeleportService/LocalPlayerArrivedFromTeleport

1 Like

Then I’d have to fire a remote event from the client to let the server know if the player has gotten the gear, right? If so, couldn’t it easily be exploited?

1 Like

Have you tried printing “joinData.TeleportData”?

1 Like

No, I’ll try that right now actually.

As you thought, the teleport data is nil. Did I mess something up while sending the data?

I know I’m not supposed to bump, but I really need to find a solution to this. I guess one way to do it is through datastores, but that doesn’t feel too reliable. What if the player leaves during teleportation? The player would keep the gear, which I don’t want them to, as it’s a one time use.

I somehow fixed this by settings a spawnpoint name. For some reason, it fixed it all.

1 Like