PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

GetJoinData

This function returns a dictionary containing information on how the Player joined the game.

The dictionary contains the fields below. Please note, whether these fields exists depends on the circumstances under which the Player joined the game.

Key Value Type Description
SourcePlaceId int64 The DataModel/PlaceId of the place the Player was teleported from. Only present if the player was teleported to the current place.
Members array An array containing the Player/UserId|UserIds teleported alongside the Player. Only present if the player was teleported in using TeleportService/TeleportPartyAsync.
TeleportData variant The teleportData parameter specified in the original teleport function. Only present if teleportData was specified and the teleport function was called from the server.

GetJoinData and TeleportData

If the teleport the Player arrived in the current place due to was initiated on a server (as opposed to a client) the Player|Player’s teleportData is included in the dictionary returned by this function.

This function can only be used to fetch teleportData on the server, to retrieve it on the client use TeleportService/GetLocalPlayerTeleportData.

In contrast to TeleportService/GetLocalPlayerTeleportData, this function provides a number of security checks to the teleportData:

  • It is guaranteed to have been sent by a Roblox server in the last 48 hours
  • It is guaranteed to have been sent with this Player
  • The SourcePlaceId returned is guaranteed to be the place the data was sent from. This means you can verify the TeleportData came from an approved place

However, as this data is transmitted by the client, it not 100% secure. Although the user cannot modify this data it is possible for them to view it or insert data from a previous teleport.

Despite this, it is still appropriate for the secure transmission of immutable data (data that can not be changed). For example, if the user has completed a level that cannot be uncompleted. Such data can be securely transmitted using this function avoiding the need to use up and wait for GlobalDataStore|DataStore requests when teleporting.

You should not use this function for data that can be changed. For example, the amount of in-game currency the user currently has. This is because GetJoinData cannot guarantee a malicious user is not transmitting data from a previous session. For data like this, you should rely on GlobalDataStore|GlobalDataStores.

As with all cases, you should implement proper server validation to ensure your game is secure. For more information see this article on Articles/Game Security.

Returns

Return Type Summary

A dictionary containing PlaceId and UserId values (see table in description).


Code Samples


Server TeleportData Example

The following code sample is an example of how teleport data can be retrieved on the server using Player/GetJoinData. This code, when ran in a Script in ServerScriptService, will listen for new Player|Players joining the game. When they join it will retrieve their teleport data (verifying it came from a valid place) to find their current level.

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

local approvedPlaceIds = {1} -- insert approved PlaceIds 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()

    -- verify this data was sent by an approved place
    if isPlaceIdApproved(joinData.SourcePlaceId) then

        local teleportData = joinData.TeleportData
        if teleportData then
            local currentLevel = teleportData.currentLevel
            print(player.Name.." is on level "..currentLevel)
        end
    end
end)