I have more than one place in my game and i want to keep the session when teleporting.
After you teleport to the second place it does not send any events, I call the isPlayerReady and gives me a false result.
Am I missing something? What do I need to do to send events?
The only thing I have found is this code on the Game Analytics page: Knowledge Base
This is the teleport script in my first place and at this point everything seems fine, it sends the events correctly.
local TeleportService = game:GetService("TeleportService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvents = ReplicatedStorage:WaitForChild("RemoteEvents")
local teleportPlayer = RemoteEvents:WaitForChild("teleportPlayer")
local ServerStorage = game:GetService("ServerStorage")
local GameAnalytics = require(ServerStorage.KPIs.GameAnalytics)
local teleporter = game.Workspace.teleportStart1
local placeId = game.Workspace.GlobalSetting.WAITING_ROOM_ID.Value
local function CompleteProgressionEvent(playersInGame)
print("complete progression event")
GameAnalytics:addProgressionEvent(playersInGame.UserId, {
progressionStatus = GameAnalytics.EGAProgressionStatus.Complete,
progression01 = "Lobby",
})
end
local function teleport(player)
-- Teleport the player
-- Teleport the player
--local teleportResult = TeleportModule.teleportWithRetry(targetPlaceID, {player})
local success, result = pcall(function()
print(player)
local playerIds = { player.UserId }
--print("playerIds ", playerIds)
local teleportData = {}
-- Add other teleport data...
teleportData = GameAnalytics:addGameAnalyticsTeleportData(playerIds, teleportData)
print("teleportData ", teleportData)
-- Call teleport function with the updated teleport data
return TeleportService:TeleportAsync(placeId, {player})
end)
if success then
local jobId = result
CompleteProgressionEvent(player)
print("Players teleported to ",jobId)
else
warn(result)
end
end
teleportPlayer.OnServerEvent:Connect(teleport)
This is the code in my second place that does not send any events.
local players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local GameAnalytics = require(ServerStorage.KPIs.GameAnalytics)
local OnPlayerReadyEvent
OnPlayerReadyEvent = OnPlayerReadyEvent or game:GetService("ReplicatedStorage"):WaitForChild("OnPlayerReadyEvent")
local function onPlayerReady(Player)
local isPlayerReady = GameAnalytics:isPlayerReady(Player.UserId)
print("isPlayerReady", isPlayerReady)
--if isPlayerReady then
--print("is player ready ", isPlayerReady)
GameAnalytics:addProgressionEvent(Player.UserId, {
progressionStatus = GameAnalytics.EGAProgressionStatus.Start,
progression01 = "Lobby",
progression02 = "Waiting_Room"
})
GameAnalytics:addDesignEvent(Player.UserId, {
eventId = "Waiting_Room",
123
})
--end
print("termino")
end
players.PlayerAdded:Connect(onPlayerReady)