How to get the amount of purchases a player has from a Roblox group using a script?

Hello, developers! :smiley:

I want to make a value on the leaderboard that shows how many clothing purchases a player made from my Roblox group.

The problem is that my role.Value part of the code does not work and I couldn’t find a solution anywhere…

If someone could aid me or explain, I would be delighted and thankful. :slight_smile:

Here is an example of my code:

function added(player)
	local ls = Instance.new("IntValue")
	ls.Name = "leaderstats"

	local role = Instance.new("StringValue")
	role.Name = "Purchases"

	role.Value = player:GetStorePurchasesInGroup(8161349)

	ls.Parent = player
	role.Parent = ls
end
game.Players.PlayerAdded:connect(added)

Basically, how do I identify the amount of purchases a player has from a Roblox group through the role.Value…?

Thanks,
bulder251 :smiley:

2 Likes

The easiest way I can think of would be to use MarketplaceService and use PlayerOwnsAsset. You could use a for loop to run through a table of AssetIds that you have in your group. If you want the amount you could probably also attach a number (price) to each AssetId in the table. Another way could be with Httpservice but that seems much harder to me.

So I would need to list over a 100 clothing asses IDs and update them every time a new clothing is made in the group?

If you don’t want to do that then you could use httpservice. I’m not too sure on the specifics though.