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

Why won't these scripts prompt a Dev Product Purchase?

The dev product is supposed to double your cash It's supposed to prompt the purchase when you click on a textbutton in StartGUI The path is: StarterGUI>ScreenGUI(named DubYourCash)>TextButton

Localscript in StarterPack:

local textButton = game.StarterGui.DubYourCash.TextButton
local productId = 22756625
 
 

textButton.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
end)

Script inside of the TextButton:



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

MarketplaceService.ProcessReceipt = function(receiptInfo) 
 

	for i, player in ipairs(game.Players:GetChildren()) do
		if player.userId == receiptInfo.PlayerId then
 
 
			
			if receiptInfo.ProductId == productId then
 
				
				player.leaderstats.Cash.Value = player.leaderstats.Cash.Value *2
			end
		end
	end	
 
	
	local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
	ds:IncrementAsync(playerProductKey, 1)	
 
	
	return Enum.ProductPurchaseDecision.PurchaseGranted		
end

1 answer

1. You should only be setting the callback ONCE on the server. The way you're currently doing it would mean that it's being set multiple times - It shouldn't be. You should be doing anything with ProcessReceipt from one server-side script in ServerScriptService.

**2. ** You need to use the button that's in the player's PlayerGui, not the one that's in the StarterGui (seeing as no player is going to click that particular button). The easiest way to do this would be to put the script into the button and just parent up to it, connecting the MouseButton1Click event.

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