It also adds a point to my leaderboard when bought.

local Button = script.Parent
local ItemID = 5334371663  --ID number of shirt
local ClickDetector = Instance.new("ClickDetector", Button)
local MS = game:GetService("MarketplaceService")

local function PurchaseItem(Player)
    local PurchaseCount = Player.leaderstats.PurchaseCount
    MS:PromptPurchase(Player, ItemID)
    for i in 0, 5 do
        local Success, playerOwnsAsset = pcall(MS.PlayerOwnsAsset, MS, Player, ItemID)
        if playerOwnsAsset then
            PurchaseCount.Value = PurchaseCount.Value + 1
        end
        wait(5)
    end
end

Click.MouseClick:Connect(PurchaseItem)

7 comments

0

You need to put the ITEM ID where it says MS:PromptPurchase(Player, ItemID) I think that should fix it!

0

ok ill try that, thanks

0

@spo0kd that wouldn't work

0

@spo0kd that wouldn't work

0

What are you trying to do? What didn't work? Please give some more information.

0

@raid6n This is entirely my fault. See: https://scriptinghelpers.org/questions/109151

0

Maybe it's because you already own the clothes -_-