LaunchData Assistance

I am trying to make a system where when a player teleports to a place, something different happens, depending on what place they joined from. I already have a simple teleportation script.

local placeId = 114881050196979


script.Parent.Touched:Connect(function (opart)
	local player = game.Players:GetPlayerFromCharacter(opart.Parent)

	if player then
		game["Teleport Service"]:Teleport(placeId, player)
	end
end)

I am not that experienced of a scripter, so is there a way to add onto this script so that something happens in a different place?

you could send a table named data inside of the teleport function cause the function goes as

Teleport(placeId : number, player : Instance, teleportData : Variant, customLoadingScreen : Instance):()

the modified script been:

if player then
	local data = {fromPlace = game.PlaceId}
	game:GetService("TeleportService"):Teleport(placeId, player, data)
end

learn about this:

so you can get something like this in any LOCAL script:

local TeleportService = game:GetService("TeleportService")
local teleportData = TeleportService:GetLocalPlayerTeleportData(player)

if teleportData and teleportData.fromPlace then
	if teleportData.fromPlace == 123 then
		-- do something 
	elseif teleportData.fromPlace == 456 then
		-- do something 
	end
end

“player” just seems to result in an unknown global in the LocalScript

That’s because “player” is not defined

already tried it, did not seem to work