A webhook sending too many request at once

This webhook is sending too many requests at once, and showing Https 429 (Too many Request)
It is apart of the anti-exploit system. It’s only happening for this part.

Part of the script that is causing this;
NOTE: Teleport Detection part wasn’t made by me, I added remote event and kick part onto it.

function AntiTeleport()
	local FirstPos = root.Position
	delay(1, function()
		local SecPos = root.Position
		if (FirstPos - SecPos).magnitude > 140 then 
			if plr.Backpack.Teleport.Value ~= true then
				if plr.Backpack.Sprint.Value ~= true then
			local reason = "Teleporting"
         game.ReplicatedStorage.ExploitLog:FireServer(plr,ID,reason)
wait(1)
		plr:kick("Exploit Detection: "..reason.." CLASSIFIED INFORMATION!")
end
end
end
end)
	end
while wait() do
	AntiTeleport()
end

REMOTE EVENT FUNCTION!

local ReplicatedStorage = game.ReplicatedStorage
wait(1)
ReplicatedStorage.ExploitLog.OnServerEvent:Connect(function(plr,ID,reason,reason)
local webhook = 'HIDDEN'
local HttpService = game:GetService("HttpService")
local data = {
		["username"] = "Exploit logs",
		["content"] = "",
		["embeds"] = {{
			["title"] = "__**Exploit log!**__",
			["description"] = "HIDDEN",
			["type"] = "rich",
			["color"] = tonumber(0xffffff),
			["fields"] = {
				{
					["name"] = "__Exploiter Player Information:__",
					["value"] = "Below",
					["inline"] = false
				},
				{
					["name"] = "__Exploiter Player Username:__",
					["value"] = tostring(plr),
					["inline"] = true
				},
				{
					["name"] = "__Exploiter Player ID (UserId)__",
					["value"] = ID.UserId,
					["inline"] = true
				},
				{
					["name"] = "__Reason:__",
					["value"] = reason,
					["inline"] = false
				}
			}
		}}
}
local newdata1 = HttpService:JSONEncode(data)
HttpService:PostAsync(webhook, newdata1)
end)

OUTPOT LOG
image

NOTE: I did clear up a lot of script from useless notes made by me.

game.ReplicatedStorage.ExploitLog:FireServer(plr,ID,reason)

The same thing functions for every other part of the script, and it only sends a request once. Any ideas on how to fix it?
It sending ~50 requests and only 5 go through to disco. But, it should only send one, so I am confused.

It works perfectly for every other request it’s only this one.

1 Like

I think that is while wait() and delay problem because function doesn’t stop loop, you should add cooldown on loop or change it to event, you can also do something like this

local fix = false
function AntiTeleport()
	fix = true
	local FirstPos = root.Position
	delay(1, function()
		local SecPos = root.Position
		if (FirstPos - SecPos).magnitude > 140 then 
			if plr.Backpack.Teleport.Value ~= true then
				if plr.Backpack.Sprint.Value ~= true then
			local reason = "Teleporting"
         game.ReplicatedStorage.ExploitLog:FireServer(plr,ID,reason)
wait(1)
		plr:kick("Exploit Detection: "..reason.." CLASSIFIED INFORMATION!")
end
end
end
end)
 wait(1)
	fix = false
	end
while wait() do
	if fix == false then
		AntiTeleport()
	end
end

Edit: Sorry for too many edits

1 Like

No worries about the edits. I will test it out!

1 Like