Hey! Recently my team and I made a new game, and initially things were going fine. The game is a collection of places in which there are lobbies that teleport players to the corresponding stories. In order to do this, we used ReserveServer of TeleportService.
As of today, we’ve been getting errors that say: “raiseTeleportInitFailedEvent: Teleport failed because This game has ended (GameEnded)”
I’m really not sure what the issue is here. It worked fine with zero bug reports for about a week, and now we’re getting more and more issues. The only thing I can think of is maybe the TeleportService freaks out if we have too many places in the game or something? Though I wouldn’t imagine that would be the case as I don’t think there’s a limit to how many places you can have in a game. For reference, we currently have 15 places in the game (12 of which are able to be teleported to as of right now).
Here’s the snippet of code that teleports players from a lobby to its corresponding starting place just in case anything here could be optimized to get rid of this issue, where id is the variable that contains the id of the queue in the array and PL is the Players service:
local serverId = TeleportService:ReserveServer(placeId)
local players = {}
for i,v in pairs(queues) do
if v.id == id then
for e,z in pairs(v.players) do
local success, err = pcall(function() -- just in case the player left
table.insert(players, PL[z])
end)
if not success then warn(err) end
end
table.remove(queues, i)
break
end
end
for i,v in pairs(players) do
queueDeparting_RE:FireClient(v) -- Fires visual event to clients in the queue
end
portalLeaving_RE:FireAllClients() -- Fires all clients with a visual and noise of the portal departing
TeleportService:TeleportToPrivateServer(placeId, serverId, players)