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

Dev product not working? Am I missing something?

--SET UP VARIABLES--

local MarketPlace = game:GetService("MarketplaceService")
local Datastore = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
DamageID = 19312506

--------------------

script.Parent.MouseButton1Down:connect(function()
MarketPlace.ProcessReceipt = function(receiptinfo)
	for i, player in ipairs(game.Players:GetChildren()) do
		if player.userId == receiptinfo.PlayerId then
			
			if receiptinfo.ProductId == DamageID then
				player.Character.Humanoid.Health = player.Character.Humanoid.Health - 20
				script.Parent.Text = player.Name .. " has bought death ! "
			end
		end
	end
	local productplayerkey = "player_" .. receiptinfo.PlayerId .. "_purchase_" .. receiptinfo.PurchaseId
	DataStore:IncrementAsync(productplayerkey, 1)
	
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
end)

1 answer

✓ Accepted answer

I'm having a similar problem but I believe I know how to fix this. I'm pretty sure that the ProcessReceipt function should be in a separate script somewhere. Your going to need to use PromptProductPurchase(player, ID) instead of simply calling the Receipt function when the player pushes the button.

2 comments

0

Hm.. alright, thanks. just not sure how to exactly make this work..

0

put script.Parent.MouseButton1Down:connect(function() PromptProductPurchase(player, ID) end) in the button, and then use the ProcessReceipt function chunk in a separate script in the Workspace.

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