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.
May someone help me?