HTTP 400 (Bad Request) Breaking my game

Hey,

In my game I have a lobby where players can step on a pad and it will teleport them to the main game. Randomly throughout the day a server will experience a Teleport to Reserved Server failed: HTTP 400 (Bad Request). After that happens the game completely breaks and players are no longer able to be teleported anymore. I’m unsure as to why it wouldn’t just restart the countdown and try teleporting again. (I have tried using Roblox’s Safe Teleport module on their wiki and that didn’t work either).
I provided screenshots and the code down below. Thanks!

pcall(function()
				local success, code = pcall(function()
					return TeleportService:ReserveServer(DESTINATION_PLACE_ID)
				end)
				
				if success and code then
					lobbyInfoPart.Status.Ready.Text = "Teleporting Players..."
			   		local teleportOptions = Instance.new("TeleportOptions")
					teleportOptions.ReservedServerAccessCode = code
					local success1, result1
			        success1, result1 = pcall(function()
			            return TeleportService:TeleportAsync(DESTINATION_PLACE_ID, readySoloPlayers, teleportOptions) 
			        end)
					--SafeTeleport(DESTINATION_PLACE_ID, readySoloPlayers, teleportOptions)
				else
					print ("Failed to Teleport Player")	
				end
			--[[local reservedServerCode = TeleportService:ReserveServer(DESTINATION_PLACE_ID)
			local teleportOptions = Instance.new("TeleportOptions")
			teleportOptions.ReservedServerAccessCode = reservedServerCode
			SafeTeleport(DESTINATION_PLACE_ID, readySoloPlayers, teleportOptions)]]--
			end

Expected behavior

Teleport the players to a reserved server and rerun the loop so that the next players who touch the pad get teleported after 60 seconds.

This happens but once the HTTP error comes up it breaks.

2 Likes

Thanks for the report! We’ll follow up when we have an update for you.

1 Like

Hi, is this still a problem you are facing? Could you please expand a bit more on your game breaking. Is it that the player is unable to trigger teleport again if they step on the pad in your game/how do you trigger this pcall? Thanks!

Hey thanks for following up,
I started from scratch and had it recoded with help from what it was before. I am still unsure why my previous code didn’t work. It is triggered by a timer that counts down and once there are enough players in the game it will call it. I can post the entire script here if you’d like to take a look. With my new teleportation system however, I am not getting the error anymore. I asked a lot of people and tried looking up reasons to why it might have been happening but I couldn’t find anything. It doesn’t happen anymore but I am curious as to why it was with my old code.

Also, once it broke the teleporting had gotten stuck on lobbyInfoPart.Status.Ready.Text = “Teleporting Players…” and didn’t go back until shutdown.

local TeleportService = game:GetService("TeleportService")
local Interactions = workspace:WaitForChild("Interactions")
local ReadyPlatform = Interactions:WaitForChild("ReadyPlatform")
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("ReleaseData2")

local ServerScriptService = game:GetService("ServerScriptService")


local sGUIs = game.ServerStorage:WaitForChild("ServerGUIs")
local RemoteEvents = game.ReplicatedStorage:WaitForChild("Remotes")
local lobbyInfoPart = workspace.Interactions:WaitForChild("LobbyInfoPart")

local MAX_PLAYERS_NEEDED = 50
local MIN_PLAYERS_TO_START = 2
local WAIT_TIME_BEFORE_STARTING = 60
local DESTINATION_PLACE_ID = 8305337434

local readySoloPlayers = {}
local Timer = WAIT_TIME_BEFORE_STARTING

local function playerIsInGame(player)
	if player == nil or game.Players:FindFirstChild(player.Name) == nil then
		return false
	else
		return true
	end
end

local function remove(player, givenTable)
	for i,v in pairs(givenTable) do
		if v == player then
			table.remove(givenTable, i)
		end
	end
end


local function SetupPlatform()
	ReadyPlatform.Touched:connect(function(hit)
		local character = hit.Parent
		local player = game.Players:GetPlayerFromCharacter(character)

		if game.PrivateServerId ~= "" and game.PrivateServerOwnerId ~= 0 then
			if player then
				local teleportOptions = Instance.new("TeleportOptions")

				local userIdToRetrieve = game.PrivateServerOwnerId

				local playerSaveKey = "ID: " .. userIdToRetrieve

				pcall(function()
					local success, playerSaveData = pcall(function()
					    return DataStore:GetAsync(playerSaveKey)
					end)

					if success and playerSaveData then
						local options = Instance.new("TeleportOptions")
						if playerSaveData.PartyReserve == nil then
							local reserve, id = TeleportService:ReserveServer(DESTINATION_PLACE_ID)
							playerSaveData.PartyReserve = reserve
							playerSaveData.PartyId = id
						end
						options.ReservedServerAccessCode = playerSaveData.PartyReserve
						TeleportService:TeleportAsync(DESTINATION_PLACE_ID, {player}, options)
					end
				end)
			end
		else
			if player and not table.find(readySoloPlayers, player) and #readySoloPlayers < MAX_PLAYERS_NEEDED and Timer > 0 then
				table.insert(readySoloPlayers, player)
				sGUIs.UnreadyPrompt:Clone().Parent = player.PlayerGui
				if game.ReplicatedStorage:FindFirstChild("PlayerData") then
					if game.ReplicatedStorage.PlayerData:FindFirstChild(player.Name) then
						local thisPlayerData = game.ReplicatedStorage:WaitForChild("PlayerData"):WaitForChild(player.Name)
						thisPlayerData.CanSpin.Value = false
					end
				end

			end
		end
	end)
	
	while true do
		readySoloPlayers = {}
		Timer = WAIT_TIME_BEFORE_STARTING
		lobbyInfoPart.Status.Ready.Text = "Waiting for more players..."
		lobbyInfoPart.Status.Players.Text = "0/"..MAX_PLAYERS_NEEDED.." Ready"
		lobbyInfoPart.Status.Players.TextStrokeColor3 = Color3.new(255/255, 0/255, 0/255)
		repeat
			wait(1)
			for i,v in pairs(readySoloPlayers) do
				if playerIsInGame(v) == false then
					table.remove(readySoloPlayers, i)
				end
			end

			lobbyInfoPart.Status.Players.Text = #readySoloPlayers.."/"..MAX_PLAYERS_NEEDED.." Ready"
			if #readySoloPlayers >= MIN_PLAYERS_TO_START then
				lobbyInfoPart.Status.Players.TextStrokeColor3 = Color3.new(0/255, 170/255, 0/255)
				Timer = Timer - 1
				lobbyInfoPart.Status.Ready.Text = "Starting in "..Timer.."..."
			else
				lobbyInfoPart.Status.Players.TextStrokeColor3 = Color3.new(255/255, 0/255, 0/255)
				Timer = WAIT_TIME_BEFORE_STARTING
				lobbyInfoPart.Status.Ready.Text = "Waiting for "..(MIN_PLAYERS_TO_START - #readySoloPlayers).." more players to ready up..."
			end
		until #readySoloPlayers == MAX_PLAYERS_NEEDED or Timer == 0
		
		if #readySoloPlayers >= MIN_PLAYERS_TO_START then
			pcall(function()

				local success, code = pcall(function()
					return TeleportService:ReserveServer(DESTINATION_PLACE_ID)
				end)
				
				if success and code then
					lobbyInfoPart.Status.Ready.Text = "Teleporting Players..."
			   		local teleportOptions = Instance.new("TeleportOptions")
					teleportOptions.ReservedServerAccessCode = code
					local success1, result1
			        success1, result1 = pcall(function()
			            return TeleportService:TeleportAsync(DESTINATION_PLACE_ID, readySoloPlayers, teleportOptions) 
			        end)
				else
					print ("Failed to Teleport Player")	
				end
			end)
			wait(5)
		end
	end
end

RemoteEvents:WaitForChild("RemoveFromQueue").OnServerEvent:connect(function(player, mode)
	local thisPlayerData = game.ReplicatedStorage:WaitForChild("PlayerData"):WaitForChild(player.Name)
	thisPlayerData.CanSpin.Value = true
	remove(player, readySoloPlayers)
end)

SetupPlatform()

Hi, it actually just occurred again for me today and broke another server. The code is completely different to see if that was the problem and it’s still giving the same HTTP 400 Error. I shut down the server so it fixes but when it happens at night and I’m not on people can’t play my game.

Hey @Randy_Moss, we recently rolled out a fix that should help in the case of teleporting groups of players to reserved servers. Are you still seeing the issue you described?

Hey thanks for getting back to me,

I just experienced the issue again about 10 minutes ago, here is a screenshot of the error:

It looks like that was a 502, whereas originally you were seeing 400 errors. Is that correct?

Sorry I should have mentioned it before but I would get both. The screenshot only showed 400 but it would be different every time it happened. I believe the 400 error was more common though. I just checked one of my severs right now and got another 400 error as well.