Hi, I’m a game creator and scripter that making some random games. Recently, I found a script on devforum, that showing all places created in one universe, just by typing UniverseId in the brackets. So, if there’s that thing available, there’s also should be an API that checking for all the badges created in the place, by typing it’s place or universe ids. So, is there’s any API to give all available badges in the game, just by joining the game?
I found this API, but it shows only 20 badges / 80+: https://badges.roblox.com/v1/universes/3487637972/badges
But anyways, I don’t know how can I retrieve them all
I tried to create this, but this isn’t working:
local http = game:GetService(“HttpService”)
local universeId = 5706399972
local data = http:GetAsync(“https://badges.roproxy.com/v1/universes/“..universeId..”/badges?limit=100&sortOrder=Asc”)if data then
data = http:JSONDecode(data)
local BadgeId = data.data.name
print(BadgeId)
end
Try this instead
local http = game:GetService("HttpService")
local universeId = 5706399972
local data = http:GetAsync(`https://badges.roproxy.com/v1/universes/{universeId}/badges?limit=100&sortOrder=Asc`)
if data then
data = http:JSONDecode(data)
local BadgeId = data.data.name
print(BadgeId)
end
Thanks, but it doesn’t changed anything. It still says nil in the console.
And also, if you put {} in the link, it won’t even work
local http = game:GetService("HttpService")
local universeId = 5706399972
local data = http:GetAsync(`https://badges.roproxy.com/v1/universes/{universeId}/badges?limit=100&sortOrder=Asc`)
if data then
data = http:JSONDecode(data)
for _, Badge in data do
print(Badge.name)
end
end
Thanks, but still says nil. (F at least 30 symbols system)
And also, it says nil two times now lol
local http = game:GetService("HttpService")
local universeId = 5706399972
local data = http:GetAsync(`https://badges.roproxy.com/v1/universes/{universeId}/badges?limit=100&sortOrder=Asc`)
if data then
data = http:JSONDecode(data)
for _, Badge in data.data do
print(Badge.name)
end
end
That’s working! Now I can retrieve all badges in the game lol
I’ve recreated the script to retrieve all badges:
local http = game:GetService(“HttpService”)
local universeId = 0 – Your place’s universeid
local data = http:GetAsync(https://badges.roproxy.com/v1/universes/{universeId}/badges?limit=100&sortOrder=Asc
)game.Players.PlayerAdded:Connect(function(Player)
if data then
data = http:JSONDecode(data)
for _, Badge in data.data do
if not game:GetService(“BadgeService”):UserHasBadgeAsync(Player.UserId, Badge.id) then
game:GetService(“BadgeService”):AwardBadge(Player.UserId, Badge.id)
end
end
end
end)
Is there any API that shows all badges count in the game?
No, but you could just count the badges using the same code as before
local http = game:GetService("HttpService")
local universeId = 5706399972
local data = http:GetAsync(`https://badges.roproxy.com/v1/universes/{universeId}/badges?limit=100&sortOrder=Asc`)
local Count = 0
if data then
data = http:JSONDecode(data)
Count = #data.data
end
print(Count)
Thanks, but it says 1 when I connected the game.
local http = game:GetService(“HttpService”)
local universeId = 5706399972
local data = http:GetAsync(https://badges.roproxy.com/v1/universes/{universeId}/badges?limit=100&sortOrder=Asc
)
local Count = 0
game.Players.PlayerAdded:Connect(function(Player)
if data then
data = http:JSONDecode(data)
for _, Badge in data.data do
Count = #data.data
Player.PlayerGui:WaitForChild(“Badges”):WaitForChild(“Count”).Text = "Badges: "…Count
if not game:GetService(“BadgeService”):UserHasBadgeAsync(Player.UserId, Badge.id) then
game:GetService(“BadgeService”):AwardBadge(Player.UserId, Badge.id)
end
end
end
end)
But at least, I don’t need to put a new badge id in the script everytime
Oh shit, I didn’t updated the universe id
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.