Hello Everyone So Basically I´m New Into Scripting and I Need Help To Script Something That Counts How Much Clothes A Player Has Already Bought On My Clothing Group, The Number Should Appear On The GUI Of My Homestore!
l Already Tried To Find This Topic Every where and Still Coudn´t Find It , So I Came Here To Ask For Help:))
Here is the GUI:))

You can use the function PlayerOwnsAsset from the service MarketPlaceService.
The two parameters are player and assetId - the player you want to check for and the clothing item’s Id (or any other item). You can loop through the table of clothing Id’s and check whether or not the player owns it; if they do then add one to the count; if they don’t, do nothing. At the end it prints how many pieces of clothing the player owns, but you can switch that to actually show the number on the gui.
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local CLOTHES_TO_CHECK = {
29138753;
34975835;
}
Players.PlayerAdded:Connect(function(player)
local count = 0
for _, clothingId in pairs(CLOTHES_TO_CHECK) do
local success, doesPlayerOwnClothing = pcall(function()
MarketplaceService:PlayerOwnsAsset(player, clothingId)
end)
if doesPlayerOwnClothing then
count += 1
end
end
print(player.Name, "owns", count, "items!")
end)
(ps. those id’s are random)
Thank You SO Much for the help! You are so nice and kind:))
If you have an extremely long list of clothing, while that script is an option it’s not exactly viable. When you’re getting into the hundreds, you’re kind of out of options.
Hi so one last question, where should i put this script, on the gui or anywhere else. and also how do i parent the text of the gui to this script
Assuming there is a text label to show how many items the player owns, you can put a LocalScript with this (slightly changed) code inside the TextLabel:
local MarketplaceService = game:GetService("MarketplaceService")
local player = game:GetService("Players").LocalPlayer
local CLOTHES_TO_CHECK = {
111111111;
}
local function getCount()
local count = 0
for _, clothingId in pairs(CLOTHES_TO_CHECK) do
local success, doesPlayerOwnClothing = pcall(function()
return MarketplaceService:PlayerOwnsAsset(player, clothingId)
end)
if doesPlayerOwnClothing then
count += 1
end
end
return count
end
script.Parent.Text = getCount()
oh tysm can i pay you! if you want send me a gamepass link here:)) ty for the help!
Thanks, but it’s fine - just a small script.