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

Selling Dev Products?

Can you help me with selling Dev Products? I made my products I just need a script that sells them. I am using a GUI and am trying to sell player points.

here's a script that doesn't work:

local buyButton = script.Parent local productId = 20139068 local Plr = script.Parent.Parent

buyButton.MouseButton1Click:connect(function() Game:GetService("MarketplaceService"):PromptProductPurchase(Plr, productId) end)

local MarketplaceService = Game:GetService("MarketplaceService")

MarketplaceService.PromptProductPurchaseFinished:connect(function(userId, productId, isPurchased) if isPurchased then

end end)

Why isn't it working? D:

1 answer

This would go in a regular script inside of the GUI Button. Make sure to read the comments. Only reason it can't be in a LocalScript is.. erm... Forgot. I remember reading it on the Wiki.

id = 20139068 --dev product id
p = script.Parent.Parent -- Make this lead to the Parent of StarterGui

script.Parent.MouseButton1Down:connect(function()
		game:GetService("MarketplaceService"):PromptProductPurchase(p, id)
local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
MarketplaceService.ProcessReceipt = function(receiptInfo) 
		if p.userId == receiptInfo.PlayerId then
			if receiptInfo.ProductId == id then
				game:GetService("PointsService"):AwardPoints(p.userId, 1) --1 is the amount of playerpoints that are awarded
		end
	end	
	
	-- record the transaction in a Data Store
	local playerProductKey = receiptInfo.PlayerId .. "_got_" .. receiptInfo.PurchaseId
	ds:IncrementAsync(playerProductKey, 1)	
	
	-- tell ROBLOX that we have successfully handled the transaction
	return Enum.ProductPurchaseDecision.PurchaseGranted		
end
end)

9 comments

0

What do you mean lead to the parent of startergui?

0

Make it lead to Game?

0

Yes.

0

19:50:12.664 - Unable to cast value to Object 19:50:12.664 - Script 'Players.Player1.PlayerGui.Shop.Frame.Hund.Script', Line 4 19:50:12.665 - Stack End

0

fixed

0

What was it?

0

Well, on my connection line, I added the variable 'p' on accident and made ROBLOX read it a WHOLEEEE different way.

0

Omg thank you soo much.

0

No problem. Help me out by accepting my answer!

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