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

DevProduct not working?

I don't get anything in the online output, I think I'm not indexing the player right because it's not damaging the player about buying the product. Help?

Server Script

--SET UP VARIABLES--

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

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


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
				local m = Instance.new("Message", game.Workspace)
				m.Text = player.Name .. " bought me"
			end
		end
	end
	local productplayerkey = receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
	Datastore:IncrementAsync(productplayerkey, 1)
	
	return Enum.ProductPurchaseDecision.PurchaseGranted
end

Local Script:

me = game.Players.LocalPlayer
buybutton = game.Workspace:FindFirstChild("BuyMe", true)
DamageID = 19312506

---

buybutton.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptProductPurchase(me, DamageID)
end)

1 answer

NEVERMIND I GOT IT, I ACCIDENTALLY PUT DAMAGEID AS A STRING. Thanks anwyays guys!!!!!

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