Error 429 (Too many requests)

Hey Devs,

I have an issue when I am trying to use HTTPService, it shows that there are too many requests.

Code:

local WebhookURL = --UrlGoesHere
local HTTPService = game:GetService("HttpService")

local Part = game.Workspace.TouchPart

while wait(5.5) do
	Part.Touched:Connect(function(hit)
		
		if hit.Parent:FindFirstChild("Humanoid") then
			local playerName = hit.Parent:GetFullName()
			
			local data = {
				["Content"] = "Player Name: ".. playerName .." recieved admin!" 
			}
			
			local finalData = HTTPService:JSONEncode(data)
			HTTPService:PostAsync(WebhookURL, finalData)
		end
	end)
end

All help appreciated!

Thanks for reading!

Try to add debounce.

local WebhookURL = ""--UrlGoesHere
local HTTPService = game:GetService("HttpService")
local debounce = false

local Part = game.Workspace.TouchPart


Part.Touched:Connect(function(hit)

	if hit.Parent:FindFirstChild("Humanoid") and debounce == false then
		local playerName = hit.Parent:GetFullName()
		debounce = true
		local data = {
			["Content"] = "Player Name: ".. playerName .." recieved admin!" 
		}

		local finalData = HTTPService:JSONEncode(data)
		HTTPService:PostAsync(WebhookURL, finalData)
		wait(10) -- A countdown before the script run again.
		debounce = false
	else
		print("Debounce is activated! Wait a little bit before trying again.")
	end
end)

I assume it is Discord webhooks. I don’t know much about webhooks but what I do know is that your script alone can’t send webhooks.

Here is a post that may help you:

1 Like

This is more of a question than an answer, because I am new to scripting in Roblox, but when I look up wait() it appears to be returning number, number instead of a boolean value (I don’t know if or how type conversions would be handled).

Whereas the while statement is probably looking for a boolean.

Have you considered something like:

while true do

and then put the wait(5.5) inside the while?

I used hyra.io with your code but code an error 400.

This is likely due to incorrect formatting/missing information with the data. Use https://embed.discord.website and change it.

  • Make sure that the URL you entered in line 1 also is correct.

No, if a while true loop has a task.wait() or wait() value, it would loop every n seconds.

But I get your confusion, when I was new to scripting I thought the same

the key is wrong
it supposed to be lowered
it should be "content"

{
["content"] = "Player Name: ".. playerName .." recieved admin!" 
}

So i add that to the start of my url?

Omg the simplest thing I got wrong. lol. Thanks!

Add your webhook URL.
But the error 400 mostly is because of incorrect formatting.
So basically overall your script had 2 problems:

  • It needed to be debounced to avoid sending too many requests.
  • Incorrect formatting:
1 Like

The error 429 is an error thrown when you exceed the rate limit of a service’s API and it is like a temporary ban from it. Your code runs in a while loop with a cooldown of 5.5 seconds which is evidently too low. Sending more requests while rate limited (in this case for discord) will get you a higher rate limit time. Increase the cooldown and try once your ban expires

it would loop every n seconds

Isn’t that what the OP was trying to do with:

while wait(5.5) do

(or am I misunderstanding something?)

Yes, I was just telling you that whle loops also work for task.wait() and wait(), since you were confused.

Thanks - coming to a new platform is always a ‘learning experience’…