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

Developer Product script not working?

I took this script from the ROBLOX wiki, and changed it to my needs (Product ID and such) but I will not work. I realize that this script is not made by me, but I would like this to work. What is wrong?

Here is the LOCAL SCRIPT in STARTER PACK:

--LocalScript in StarterPack
-- setup local variables
local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton
local productId = 21457157
 
-- when player clicks on buy brick prompt him/her to buy a product
buyButton.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
end)
 
 
 
 

And here is the script in the buybutton thing:

 
 --Script in BuyButton part
-- setup local variables
local MarketplaceService = game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 21457157
 
-- define function that will be called when purchase finished
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
 
				-- handle purchase
				player.leaderstats["Maple Leaves"].Value = player.leaderstats["Maple Leaves"].Value + 1000
			end
		end
	end	
 
	-- record the transaction in a Data Store
	local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
	ds:IncrementAsync(playerProductKey, 1)	
 
	-- tell ROBLOX that we have successfully handled the transaction
	return Enum.ProductPurchaseDecision.PurchaseGranted		
end

1 answer

Did you create the button? You can go into ROBLOX studio create a sign with "TextButton" after that insert the button script into it

If that didn't work message me and I'll help you to the best of my ability.

2 comments

0

I did create the button. I basically just copied the model and changed it to my liking.

0

Send me a message on ROBLOX giving me the link to the model and I'll fix it

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