So this devproduct script is supposed to give a tool to the player if he buys the dev product. It doesn't want to work sometimes. When I try it, it does nothing.. so here it is:
local devProductId = 48808572
local pl = script.Parent.Parent.Parent.Parent.Parent
script.Parent.MouseButton1Click:connect(function()
game:GetService("MarketplaceService"):PromptProductPurchase(pl, devProductId)
end)
local MarketplaceService = game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
MarketplaceService.ProcessReceipt = function(receiptInfo)
for i, player in ipairs(game.Players:GetChildren()) do
if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == devProductId then
local P = game.Players:FindFirstChild(player.Name)
local miniguncopy = game.ServerStorage.MiniGun:Clone()
miniguncopy.Parent = P.Backpack
end
end
end
local playerProductKey = "pl_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.ProductId
ds:IncrementAsync(playerProductKey, 1)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
