Developer Product script not working, and can it be done more simple?
local MarketplaceService = game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
First = 35587367
Second = 35587494
MarketplaceService.ProcessReceipt = function(receiptInfo)
local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId
local numberBought = ds:IncrementAsync(playerProductKey, 1)
for i,v in pairs (game.Players:GetChildren()) do
if v.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == First then
local lds = v:FindFirstChild("leaderstats")
if lds ~= nil then
local cs = lds:FindFirstChild("Money")
if cs ~= nil then
cs.Value = cs.Value + 500
elseif receiptInfo.ProductID == Second then
local lds = v:FindFirstChild("leaderstats")
if lds ~= nil then
local cs = lds:FindFirstChild("Money")
if cs ~= nil then
cs.Value = cs.Value + 1000
end
end
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
end