HTTP 429 (Too Many Requests) in a Place Teleport Function

Hi I am having an annoying HTTP 429 (Too Many Requests) error in my game when I teleport players from a place to another place.

The error I get:

my code:

-- ===========================================================================
-- Roblox Services
-- ===========================================================================
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TeleportService = game:GetService("TeleportService")
local MarketplaceService = game:GetService("MarketplaceService")

-- ===========================================================================
-- Dependencies
-- ===========================================================================
local Packages = ReplicatedStorage.Packages
local Component = require(Packages.Component)
local ServerType = require(ReplicatedStorage.Modules.ServerType)
local Cooldown = require(ReplicatedStorage.Modules.Cooldown)
local JoinCooldown = Cooldown.new()
local Trove = require(Packages.Trove)
local Knit = require(Packages.Knit)
local ReplionServer = require(Packages.Replion).Server
local Products = require(ReplicatedStorage.Configs.AllPurchasables)
-- local targetPlaceId = 15089477471
-- ===========================================================================
-- Variables
-- ===========================================================================

-- ===========================================================================
-- Components
-- ===========================================================================
local PlaceTeleportComponent = Component.new({
	Tag = "PlaceTeleport",
	Ancestors = {
		workspace,
	},
	Extensions = {},
})

-- ===========================================================================
-- Internal Methods
-- ===========================================================================

-- ===========================================================================
-- Public Methods
-- ===========================================================================
function PlaceTeleportComponent:teleportPlayers(instance)
	instance.Door.ProximityPrompt.Enabled = false
	local tpPlayers = {}
	for _, playerTag in pairs(instance.Players:GetChildren()) do
		local player = game.Players:FindFirstChild(playerTag.Name)
		if player then
			table.insert(tpPlayers, player)
			if self.delayed then
				local PlayerReplion = ReplionServer:WaitReplionFor(player, "PlayerData", 10)
				if not PlayerReplion then
					warn(player, "PlayerReplion not found")
					continue
				else
					PlayerReplion:Set("BossDelay", 900)
				end
			end
		end
	end
	print("Teleporting players...", self.delayed)
	instance.Players:ClearAllChildren()
	if #tpPlayers > 0 then
		local teleportOptions = Instance.new("TeleportOptions")
		teleportOptions.ShouldReserveServer = true
		teleportOptions:SetTeleportData({
			ChosenMap = instance:GetAttribute("Map"), -- TODO: Determinar o mapa
			ServerType = ServerType,
		})
		--TeleportService:SetTeleportGui(TeleportGui)
		print("CallTeleportAsync")
		TeleportService:TeleportAsync(15562713515, tpPlayers, teleportOptions) -- ERROR HAPPENS HERE
	end
	task.wait(5)
	instance.Door.ProximityPrompt.Enabled = true
end
-- ===========================================================================
-- Component Initialization
-- ===========================================================================
--[[
    Construct is called before the component is started.
    It should be used to construct the component instance.
]]
function PlaceTeleportComponent:Construct()
	self.Trove = Trove.new()
	self.Trove:AttachToInstance(self.Instance)
end

--[[
    Start is called when the component is started.
    At this point in time, it is safe to grab other components also bound to the same instance.
]]
function PlaceTeleportComponent:Start()	
	self.PromptService = Knit.GetService("PromptService")
	local instance = self.Instance
	local trove = self.Trove
	local startedCount = false
	self.delayed = instance:GetAttribute("Delayed")
	local prompt = instance.Door.ProximityPrompt
	local playersInside = instance.Players
	instance.Door.SurfaceGui.Time.Text = instance:GetAttribute("Map")
	instance.Door.SurfaceGui.Count.Text = "0/" .. instance:GetAttribute("MaxPlayers")

	trove:Add(prompt.Triggered:Connect(function(player)
		local maxPlayers = instance:GetAttribute("MaxPlayers")
		if player then
			local PlayerReplion = ReplionServer:WaitReplionFor(player, "PlayerData", 10)
			if not PlayerReplion then
				return
			end
			if self.delayed then
				if PlayerReplion:Get("BossDelay") > 0 then
					MarketplaceService:PromptProductPurchase(player, Products.SkipBossDelay)
					return
				end
			end
			if JoinCooldown:IsInCooldown(player) then
				return
			end
			JoinCooldown:Add(player, 1)
			local character = player.Character
			if character then
				if not playersInside:FindFirstChild(player.Name) then
					if #playersInside:GetChildren() >= maxPlayers then
						return
					end
					local playerTag = Instance.new("StringValue", playersInside)
					playerTag.Name = player.Name
					character:PivotTo(instance.Inside.CFrame)
					self.PromptService.Client.ChangePrompt:Fire(player, prompt, "Leave")
				else
					playersInside[player.Name]:Destroy()
					character:PivotTo(instance.Outside.CFrame)
					self.PromptService.Client.ChangePrompt:Fire(player, prompt, instance:GetAttribute("Map"))
				end
			end
		end
	end))

	trove:Add(playersInside.ChildAdded:Connect(function()
		local maxPlayers = instance:GetAttribute("MaxPlayers")
		if not startedCount and #playersInside:GetChildren() > 0 then
			startedCount = true
			for x = 10, 0, -1 do
				instance.Door.SurfaceGui.Time.Text = x
				instance.Door.SurfaceGui.Count.Text = #playersInside:GetChildren()
					.. "/"
					.. instance:GetAttribute("MaxPlayers")

				if #playersInside:GetChildren() == maxPlayers then
					instance.Door.SurfaceGui.Time.Text = "Teleporting..."
					self:teleportPlayers(instance)
					instance.Players:ClearAllChildren()
					break
				end
				if #playersInside:GetChildren() < 1 then
					instance.Door.SurfaceGui.Time.Text = instance:GetAttribute("Map")
					instance.Door.SurfaceGui.Count.Text = #playersInside:GetChildren()
						.. "/"
						.. instance:GetAttribute("MaxPlayers")
					startedCount = false
					break
				end
				task.wait(1)
			end
			if #playersInside:GetChildren() > 0 then
				instance.Door.SurfaceGui.Time.Text = "Teleporting..."
				self:teleportPlayers(instance)
				instance.Players:ClearAllChildren()
			end
			instance.Door.SurfaceGui.Time.Text = instance:GetAttribute("Map")
			instance.Door.SurfaceGui.Count.Text = #playersInside:GetChildren()
				.. "/"
				.. instance:GetAttribute("MaxPlayers")
			startedCount = false
		end
	end))
end

--[[
    Stop is called when the component is stopped.
    This is called when the bound instance is removed from the whitelisted ancestors or when the tag is removed from the instance.
]]
function PlaceTeleportComponent:Stop()
	self.Trove:Destroy()
end

return PlaceTeleportComponent

This error is breaking my game Teleports. :frowning:
May someone help me?

1 Like

Oi, boa noite, me chamo | Noel @PCgamerbom sou brasileiro, Rio de janeiro

O erro “HTTP 429” está acontecendo porque o script está tentando armazenar informações em um curto período de tempo e também tente rever se tem muito “LOOPS NA API”.

  • O que seria Loops na api ???
    E aquela determinada parte onde o script precisa obter informações ou enviar dados para o serviço, talvez o erro seria numa dessas 2 coisas, tente minimizar o script para obter um certo sucesso ou encurtar o período de tempo entre o “TELEPORT PLACE”.

Veja nesta documentação do Roblox: TELEPORT SERVICE