Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a script that counts every badge that a player owns and display it?

so i have this script it gets about 100 badges from the player and in one post a guy said to use a loop and i also dont know how to change the data to int value.

here is the code:

game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("Folder", player)
    leaderstats.Name = "leaderstats"

    local badges = Instance.new("IntValue", leaderstats)
	    badges.Name = "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")
		print(Badges)
	    toReturn  = tonumber(Badges);
	    return toReturn
	end;
	fetchBadges(player.userId, 100)
	badges.Value = toReturn
end)

1 answer

In the Badges API there is a third parameter for specifying the cursor. Basically when you make a request to return the player's 100 badges, it includes a key called nextPageCursor, which is a parameter that you'd include in your link to get the next page. By using a loop he meant keep sending requests with the cursor parameter included until there is no more next page.

1 comment

0

and what should the third parameter be exactly?

This discussion is preserved as it was. New answers, comments, and votes are closed.