local Players = game:GetService("Players")
local function onPlayerAdded(player)
local source = player:GetJoinData()
-- Check if the provided source is valid
if source then
-- Read eventId from GameJoinContext
local eventId = source.GameJoinContext.EventId
if eventId then
print(player.Name, "joined from the event:", eventId)
end
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
Hello @MagicLuau , the reason you are running into this error is because this code sample is specifically running to track the event ID when a player joins an experience through an event entry point, such as by clicking on an event notification or through the join button on the event details page. This process allows the event ID to be added to the player’s GameJoinContext; if they didn’t join from an event, you will run into an error.
Its exactly the issue, it should be probably be good to add a check if there is no such gamejoincontext to prevent users to encounter the following issue.