Grow a garden affecting other games and script to prevent badgeService from breaking

This works for your purpose but you should also make it so it tries again if it fails.

Something like:

local function hasBadge()
    local Status
    local Success, Error = pcall(function()
		Status = Service:UserHasBadgeAsync(UserID, BadgeID)
	end)
    return Status, success
end
function Badge.CheckIfUserHasBadge(UserID, BadgeID)
	local Status, success
	local count = 0
	while true do
       Status, success = hasBadge()
       count += 1
       if (Status and success == true) or count > 4 then break end -- don't overdo it
       task.wait(0.1)
    end
	
	return Status
end

BadgeService shouldn’t just go down randomly, sometimes it can fail so it’s good practice to try again.

4 Likes