Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Dev Product Reciept Not Working?

I put a regular script into the Starterpack. (Unsure if this is the problem.) I'm trying to send leaderstats NumberValue "Coins". Purchasing works, but sending the "Coins" won't. Any help on how to fix this?

local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")

MarketplaceService.ProcessReceipt = function(receiptInfo)
	print("Testing Receipt Loaded")
	local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId
	local numberBought = ds:IncrementAsync(playerProductKey, 1)
	for i,v in pairs (game.Players:GetChildren()) do
		if v.userId == receiptInfo.PlayerId then
			if receiptInfo.ProductId == 19918045 then
				print("Did this succeed?")
			
			
				lds = v:FindFirstChild("leaderstats")
				if lds ~= nil then
					cs = lds:FindFirstChild("Coins") 
					if cs ~= nil then
						cs.Value = cs.Value + 100
						print("Coins Sent") 
					end
				end
			end
		end
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted		
end

1 answer

✓ Accepted answer

The normal script should go into ServerScriptStorage or Workspace (or somewhere that it won't be cloned like it does in the Backpack)

1 comment

0

It works! Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.