I’ve got this script that gets Group Members via HTTP but i’m getting the Error code: HTTP 429 (Too Many Requests) Note it’s not always but its about 50/50
Script:
local part = game.Workspace.Part
local part2 = game.Workspace.Part2
local GroupService = game:GetService(“GroupService”)
local Players = game:GetService(“Players”)
local HttpService = game:GetService(“HttpService”)
GroupID = nil
local function playerAdded(player)
wait(2)
local groups = GroupService:GetGroupsAsync(player.UserId)
for _, groupInfo in pairs(groups) do
for key, value in pairs(groupInfo) do
if groupInfo.IsPrimary then print(groupInfo.Name,groupInfo.Id)
GroupID = groupInfo.Id
part2.Decal.Texture = (groupInfo.EmblemUrl)
part.SurfaceGui.GroupNameText.Text = (groupInfo.Name)
end
end
end
end
Players.PlayerAdded:Connect(playerAdded)
wait(5)
local groupData = HttpService:JSONDecode(HttpService:GetAsync(“https://groups.rprxy.xyz/v1/groups/“..GroupID..””))
part.SurfaceGui.MembersText.Text = (groupData.memberCount)
This means that you’re sending to many request to the Web Server that is hosting the api.
You could avoid hitting rate limits by making a request at certain intervals.
This is nothing you can fix rather than have good practices, and only make requests when you need too.
Although your rate-limit may reset in about 15 minutes -1h Somewhere in that range. And you’ll be good. As this is the time most Api’s use when setting their rate limits.
I’ve had this issue before, in my case here I needed to retrieve a person’s outfit from their ID and I constantly kept getting the “too many requests” error.
My script loops through 2 pages of the players outfits and checks if its a bundle or not before using them further, i used task.spawn() functions to load both pages in advance, see what you can learn from it.
-- lv_ver
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local HttpService = game:GetService("HttpService")
local GetPlayerOutfitsEvent = ReplicatedStorage:WaitForChild("GetPlayerOutfitsEvent")
local function GetPlayerOutfits(userid)
local ProxyUrl = "https://avatar.roproxy.com/v1/users/%d/outfits?page=%d"
local Outfits = {}
local function fetchPage(PageNumber)
local RequestUrl = string.format(ProxyUrl, userid, PageNumber)
local Success, Result = pcall(HttpService.GetAsync, HttpService, RequestUrl)
if Success and Result then
local success2, result2 = pcall(HttpService.JSONDecode, HttpService, Result)
if success2 and result2 and result2.data then
local pageOutfits = {}
for _, outfitItem in ipairs(result2.data) do
if outfitItem["isEditable"] then
table.insert(pageOutfits, {
id = outfitItem["id"],
name = outfitItem["name"]
})
end
end
return pageOutfits
end
end
return nil
end
local outfits1, outfits2
local success1, success2
task.spawn(function()
outfits1 = fetchPage(1)
success1 = outfits1 ~= nil
end)
task.spawn(function()
outfits2 = fetchPage(2)
success2 = outfits2 ~= nil
end)
while outfits1 == nil or outfits2 == nil do
task.wait(0.1)
end
if success1 then
for _, outfit in ipairs(outfits1) do
table.insert(Outfits, outfit)
end
end
if success2 then
for _, outfit in ipairs(outfits2) do
table.insert(Outfits, outfit)
end
end
return Outfits
end
GetPlayerOutfitsEvent.OnServerEvent:Connect(function(player, userId)
local outfits = GetPlayerOutfits(userId)
GetPlayerOutfitsEvent:FireClient(player, outfits)
end)
Sorry for the (extremely) late response, I was looking for solutions as well but managed to come up with this.