So when I join my game, I start with 850 gems, then when I buy this, I get 900. But if in game I set my gem amount to 0, and then I buy it, It gives me my previous amount (900) plus 50, instead of 0 + 50, giving me 50. Can some please tell me why this is happening, and how to fix it? thx! :)

local function processReceipt(receiptInfo)
	local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
	local productId = receiptInfo.ProductId
	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	if productId == 453120071 then
		player:WaitForChild("leaderstats").Gems.Value = player:WaitForChild("leaderstats").Gems.Value + 50
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
end

MarketplaceService.ProcessReceipt = processReceipt

3 comments

2

The likely reason is that you are setting the value to zero on the client, which means that the server can't detect it. The solution would be changing the value from the server. There should be a button that you can click in studio that turns it to "Current Server" or something like that.

0

Would using the command bar work?

0

Make sure you are 100% setting the players gems to 0 on SERVER side... Like print their gems out after you attempt to set them. Ping me in chat when you have tested it. :)