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

Using DevProducts on a TextButton?

I used a template for this but instead of a surface gui I need it to work on a TextButton. No Output besides "Place has to be opened with edit button to access DataStores"

local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 19181612
local cookiesincrease = 1000

-- define function that will be called when purchase finished
--script.Parent.MouseButton1Click:connect(function(click)
	MarketplaceService.ProcessReceipt = function(receiptInfo) 
	
		-- find the player based on the PlayerId in receiptInfo
		for i, player in ipairs(game.Players:GetChildren()) do
			if player.userId == receiptInfo.PlayerId then			
	
				-- check which product was purchased
				if receiptInfo.ProductId == productId then
					
					game.Workspace.cookies = game.Workspace.cookies + cookiesincrease
				end
			end
		end	
		
		-- record the transaction in a Data Store
		local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
		ds:IncrementAsync(playerProductKey, 1)	
		
		
		return Enum.ProductPurchaseDecision.PurchaseGranted		
	end
--end)

2 comments

0

What this script is for is to process when someone buys that Dev Product.

0

I'm trying to get it to pop up saying "Would you like to purchase this product" or whatever it says. :P

2 answers

Put in local in text-button

Here:

lMPS = game:GetService("MarketplaceService")
id = 653936051 
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
	MPS:PromptProductPurchase(player, id)
end)

I have used this script in another answer before this is risky...

You need to go play your game like you play any other game on roblox. When you are in the game, just press F9 and look at the Server Console and Local Console for problems.

1 comment

0

No output in dev console

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