I know this isn't as complicated as I am making it.

I made a script in my store to increase leaderstat value "Purchases" by +1 when a clothing item (Shirt, Pant, etc) is purchased.

local mpService = game.getService("MarketplaceService")

mpService.ProcessReceipt = function(purchaseInfo)
    local plr = game:getService("Players"):GetPlayerByUserId(purchaseInfo.PlayerId)
    if purchaseInfo.ITEM_ID == 123456 then
        --The value that will be incremented
        local Purchases = plr.leaderstats.Purchases;
        Purchases.Value = Purchases.Value +1
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted
end

"123456" is just a place holder for the actual assetId.

I have a simple leaderstat script:

function onPlayerEntered(newPlayer)
		local stats = Instance.new("IntValue")
	stats.Name = "leaderstats"

	local score = Instance.new("IntValue")
	
	score.Name = "Purchases"
	score.Value = 0

	score.Parent = stats	
	stats.Parent = newPlayer
end

game.Players.ChildAdded:connect(onPlayerEntered)

Any ideas why this is not communicating? THANKS

3 comments

0

Is the first script a LocalScript or ServerScript?

0

Server... But I tried local as well

0

Bump