UserHasBadge error "TooManyRequests"

The problem is I have a inventory based on if the player owns the badge or not. So lets say they own a certain badge then the item appears in their inventory. But the code is outputting “TooManyRequests”.

I have tried UserOwnsBadgeAsync and many other BadgeService methods. (Im new to BadgeService)

Any help is appreciated!

You are sending too many requests to UserOwnsBadgeAsync. Try putting a task.wait() in the loop.

I added task.wait() after the start of the for loop and it still outputs the same error

Did you put it in the loop?

(30)

Use BadgeService

like this:

local Badge = 238713981731
local BadgeService = game:GetService("BadgeService")
local player = "idk"

if not BadgeService:UserHasBadge(player.UserId, BadgeId) then
    BadgeService:AwardBadge(player.UserId, badgeId)
end

this should work (i think), i cant test it because i am banned from roblox

oh wait you already have that in the code

Yes I put it in the loop --------

That would work. But its the table loop that is making it repeat the call over and over again making it “TooManyRequests”. I want to call all the functions without it being “TooManyRequests”. Also, I dont want the player to receive the badge if they do not own it.

Update: The inventory loads fine. But after I die and it needs to update again it errors “TooManyRequests”:

pcalls yoo

i dont know how to use pcalls but it might be the solution because it removes those error thingies

But if “TooManyRequests” is outputted the rest of the pcall would result in errors? That would mean that most of the items in the inventory wouldnt be loaded.

What if the player has inventory off? How do you check if they have it that way?

yo this post has pcalls in it blue text thingy that redirects you to that page

{ click it }

( plz )

Wait so if there inventory is off then we cannot detect if they own the badge via BadgeService:UserHasBadge?

Ive used a pcall function in this code before. It ouputted many warnings and it didnt load in the players inventory. (The code was correct)

Probably not. Then it would be a way of bypassing ROBLOX inventory private thingy ig

Actually I think ive found a solution. I would save each badge (BoolValue) to the datastore. And use the inventory system based of the datastore.

I will report back if this works or not.

Update: It worked like a charm. I created a boolvalue for every badge there was and assigned values to it (true if they owned it, false if they didnt). And changed my inventory script to fit these features. Thanks for the help!