To begin, I want to find a way to make my code not yield forever.
So the problem is whenever I try to use “:UserHasBadgeAsync()” it yields infinitely rather than erroring or responding. The weirdest part is it only happens with 1 specific badge.
local badgeOwned = cacheOwnedBadges[player.UserId][badge]
if badgeOwned == nil then
local worked, data = pcall(function()
badgeOwned = game:GetService("BadgeService"):UserHasBadgeAsync(player.UserId, badge)
end)
end
Any help solving this issue would be greatly appreciated!
badgeOwned stores the value at the current time. Changing it later on in the script does not change the value in the table. The correct code would be
local badgeOwned = cacheOwnedBadges[player.UserId][badge]
if badgeOwned == nil then
local worked, data = pcall(function()
cacheOwnedBadges[player.UserId][badge] = game:GetService("BadgeService"):UserHasBadgeAsync(player.UserId, badge)
end)
end
Mine does have a cache, you are overlooking the ACTUAL issue. The code sample I used was only the necessary elements. The cache is updated later in the script.
REMEMBER
The actual issue is that “:UserHasBadgeAsync()” is yielding without timing out, erroring, or returning.
The local worked, data was used earlier in testing to find the issue and isn’t actually a part of the script. The yield is in the snippet I added. Its yielding on the line UserHasBadgeAsync is used but only when I use THIS (657163782152408) badge id.