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

Can someone help me to fix this tool developer product script?

i need it to be fix it will not give you the tool

local productId = 19864337

-- 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.
				print("Giving "..game.Players.LocalPlayer.Name.." a Master Key.")
MasterKey = game.Lighting.MasterKey:Clone() 
MasterKey.Parent = game.Players.LocalPlayer.Backpack

				-- more feedback for the player.
				game.Workspace.DisplayScreen.SurfaceGui.TextBox.Text = player.Name .. " has purchased A Master Key."
			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

Hopefully this works... NOTE: This is for GUI.

local Market = Game:GetService("MarketplaceService")
local Player = script.Parent.Parent.Parent.Parent
local Assets = {19864337}

script.Parent.MouseButton1Down:connect(function()
    Market:PromptProductPurchase(Player, Assets[1])
end)

Market.PromptProductPurchaseFinished:connect(function(userId, assetId, Purchased)
    if userId == Player.userId then
        if Purchased == true then
           print("Giving "..Player.." a Master Key.")
	   MasterKey = game.Lighting.MasterKey:Clone() 
	MasterKey.Parent = Player.Backpack
            wait(5)
        else

        end
    end
end)

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