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?
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