Hi, if I had a system where I want a player to go from level to level from the main menu and when the first level is completed I want to send data saying so to the main menu so the second is unlocked, how would I do it using TeleportService:GetLocalPlayerTeleportData? Do I make a Boolean in the main menu and if yes how would I use teleport data to make it true? Pls help
1 Like
From my experience i’d say that you should get the teleportData from a script in ReplicatedFirst
(not `ReplicatedStorage) so the data is gotten as soon as possible.
So you’d basically listen for TeleportService.LocalPlayerArrivedFromTeleport. And the data is in the SECOND PARAMETER so just remember that
TeleportService.LocalPlayerArrivedFromTeleport:Connect(function(loadingGui, data)
print(data)
end)
Then from here, you can send like the level they just beat or the next level they’re going to. Check which level it is, and enable them to go to the next level
Yeah
(the reply above is probably better since it has retry throttling)
2 Likes
Example for setting up teleport data:
local TeleportService = game:GetService("TeleportService")
local player = game.Players.LocalPlayer
local teleportData = {
Level2Unlocked = true
}
TeleportService:SetLocalPlayerTeleportData(teleportData)
retrieve data:
local TeleportService = game:GetService("TeleportService")
local player = game.Players.LocalPlayer
local teleportData = TeleportService:GetLocalPlayerTeleportData()
if teleportData and teleportData.Level2Unlocked then
unlockLevel2()
end
function unlockLevel2()
print("Level 2 is now unlocked!")
end
`
reset teleport data:
TeleportService:SetLocalPlayerTeleportData(nil)
K thanks you guys are the bwst
1 Like