Alright, so i know there is Player.AccountAge which displays the players account age, but im wondering if there is a way to display a players Badge count?
Would i have to use HTTP service or is there a easier way?
Any help is appreciated <3
Alright, so i know there is Player.AccountAge which displays the players account age, but im wondering if there is a way to display a players Badge count?
Would i have to use HTTP service or is there a easier way?
Any help is appreciated <3
I did a quick search on the Roblox API, and I believe that you do need to use HTTP service.
It would look something like this:
local HTTP = game:GetService"HttpService"
local function getAmountOfBadges(userId)
local badges = HTTP:GetAsync("https://badges.roblox.com/v1/users/" .. userId .. "/badges?limit=100&sortOrder=Asc")
local amountOfBadges = #(badges.data)
return amountOfBadges
end
Makes sense, is it possible to display the badge ammount number on a textlabel?
Im thinking maybe Label.Text = badge.Ammount or something like that?
Since that endpoint limits you to 100 results, you’ll most likely have to use a while loop until you reach the end page. And also, you’ll only be able to retrieve the badges of users that have their inventories un-privated.
This seems extremely useful, but I thought I remembered there being a rule for HTTPService which didn’t allow players to use it with the actual ROBLOX website. It’s probably just my faulty memory, but just in case anyone can agree with me on that, does this code have some sort of workaround I didn’t notice?
EDIT: Nevermind, the reply above mine answered my question.
Ah yeah, I forgot about that. You’ll have to use a proxy in order to make the request to Roblox. Luckily, Froast has provided an open source proxy which will work for this. Instead of using the original endpoint, you’ll have to access the data by replacing roblox.com
with rprxy.xyz
.
https://badges.rprxy.xyz/v1/users/{UserId}/badges?limit=100&sortOrder=Asc
Here’s something that would get the amount of badges.
local Http = game:GetService("HttpService");
local fetchBadges = function(userId, badgeLimit)
local Badges = Http:GetAsync("https://badges.rprxy.xyz/v1/users/" .. userId .. "/badges?limit=" .. badgeLimit .. "&sortOrder=Asc")
local toReturn = tonumber(#Badges.data);
return toReturn
end;
is there a way to display it on a textlabel, kinda like this
(script in the text label)
local LAB = script.Parent
local Http = game:GetService("HttpService");
local fetchBadges = function(userId, badgeLimit)
local Badges = Http:GetAsync("https://badges.rprxy.xyz/v1/users/" .. userId .. "/badges?limit=" .. badgeLimit .. "&sortOrder=Asc")
local toReturn = tonumber(#Badges.data);
return toReturn
end;
LAB.Text = (#Badges.data)
sorry im new to http and have no idea how to use Http <3
I don’t use HTTP service to check badges. I just use the badge ID and script the check.
Since the fetchBadges()
function returns the amount of badges, you can just set the text to that
LAB.Text = fetchBadges(userId, badgeLimit)
Yes you can, also make sure to mark this as your solution so other people know that your issue has been resolved.
I am assuming this is put in a localscript and the parent is the TextLabel.
local Players = game:GetService("Players");
local Http = game:GetService("HttpService");
local Player = Players.LocalPlayer;
local Label = script.Parent;
local fetchBadges = function(userId, badgeLimit)
local Badges = Http:GetAsync("https://badges.rprxy.xyz/v1/users/" .. userId .. "/badges?limit=" .. badgeLimit .. "&sortOrder=Asc")
local toReturn = tonumber(#Badges.data);
return toReturn
end;
local Badges = fetchBadges(Player.UserId, 100) -- You can change 100 if you want
Label.Text = tonumber(Badges)
Oh, you should message me privately I’ll help you with that.
Did you read what I previously said?