RemoteEvents or TeleportService getting overloaded easily?

Hi, I’ve been getting a very strange bug that I can’t seem to find anywhere on the internet? (i think i looked hard enough)
But for some reason, my code just breaks every time the game gets alot of players (it doesnt look like a coincidence)

So I have a “reserve server” teleport in my game that fires when Onclientevent and it seems to work fine the whole day with 4K+ CCU then i notice that every time the game starts gaining 6-8K, the players just dip instantly and the game falls down to 1-2K CCU within 5 minutes and loads of bug reports about the game not teleporting them.
It seems like more than half of players get the issue but the other half don’t, including me.
I’ve tried hopping to every server while the bug was ongoing but I could not replicate it myself.

Shutting down servers seems to fix the problem but I obviously don’t want to do that everyday, and sometimes the bug just fixes itself after an hour, while I’m asleep and not on studio.
I’ll show the client and server code for the teleport and if there’s anything very wrong with the code, please let me know!

CLIENT:

Singleplayer.MouseButton1Click:Connect(function()
	RS.Singleplayer:FireServer()
	
	task.wait(20)
	
	--CODE HERE THAT TELLS PPL TO SAY "BUG #1" in group wallgroupwall."
end)

SERVER:

TPS.TeleportInitFailed:Connect(function(plr,result,errormsg)
	warn(result,errormsg)
	--CODE HERE THAT TELLS PPL TO SAY "BUG #6" in group wall
end)

function reserveServerWithRetry(placeId, retries, plr) --this makes the teleport retry 6 times if accesscode fails
	local success, accessCode
	for i = 1, retries do
		success, accessCode = pcall(TPS.ReserveServer, TPS, placeId)
		if success then return accessCode --CODE HERE THAT TELLS PPL TO SAY "BUG #5.5" in group wall
		else warn(accessCode)
		end
		warn("Retrying ReserveServer: Attempt " .. i)
		task.wait(2)
	end
	--CODE HERE THAT TELLS PPL TO SAY "BUG #5" in group wall
	error("Failed to reserve server after " .. retries .. " attempts.")
end

RS.Singleplayer.OnServerEvent:Connect(function(plr)
	if not plr or not plr.Parent then
		warn("Player not available.")
		--CODE HERE THAT TELLS PPL TO SAY "BUG #4" in group wall
		return
	end

	local success, output = pcall(function()
		local Access = reserveServerWithRetry(PlaceId, 6, plr)

		if Access then
			TPS:TeleportToPrivateServer(PlaceId, Access, {plr})
		else
			--CODE HERE THAT TELLS PPL TO SAY "BUG #3" in group wall
			error("Failed to reserve server.")
		end
	end)

	if not success then
		warn("Teleport failed: " .. output)
		--CODE HERE THAT TELLS PPL TO SAY "BUG #2" in group wall
	end

Whenever the game breaks, I ONLY get people saying “bug #1” and nothing else so I was starting to think that it could be about the RemoteEvents?
I’ve also been getting these errors in error report and I’m not sure if this really has anything to do with my problem.

1 Like

Looking at the errors it might be that several servers are trying to reserve at once, making it so that Roblox decides which servers to reserve and fails the others

2 Likes

Can too much of server reserving across multiple servers be a cause for all servers too? What’s a good workaround if so?

1 Like

You should try adding a debounce to the local side, ReservedServers take time to set up and if anyone manages to press the button several times (example: an autoclicker), it could break TeleportService for some time

I did try using “MouseButton1Click:Once(function()” the first time, which should act as a debounce, but it still didn’t work. I changed it to :Connect() because I wasn’t sure what was causing the problem and I was hoping it would make the issue less common. As far as I can tell, the debounce didn’t make it better or worse for some reason.

It seems like a majority of the errors are coming from the server, with 10k on previous teleporting thing, but if people are only saying bug #1, I would need to see more of the local side because currently it doesn’t make sense how the client would be related at all (except for firing the RemoteEvent)

Actually, I might have found the issue ‘:TeleportToPrivateServer’ is deprecated as stated in the TeleportService Documentation, try this code out and see if the issue goes away:

local success, output = pcall(function()
		local Access = reserveServerWithRetry(PlaceId, 6, plr)
		local TeleOptions = Instance.new("TeleportOptions")
		TeleOptions.ReservedServerAccessCode = Access

		if Access then
			TPS:TeleportAsync(PlaceId, {plr}, TeleOptions) -- Takes in PlaceId, Players, and TeleportOptions (instance)
		else
			--CODE HERE THAT TELLS PPL TO SAY "BUG #3" in group wall
			error("Failed to reserve server.")
		end
	end)
1 Like

Thanks for your help! I’ll try using that. I had no idea “TeleportToPrivateServer” was deprecated so maybe it could be the issue, if not, then it was a good shot.
And about people only saying “bug #1,” I would assume it’s because the server side isn’t outputting any errors despite it not teleporting people properly. Bug #1 just outputs from client when they don’t teleport and they’re still in the same server after 20 seconds AND there’s no real “errors” coming from serverside.

1 Like