I put a regular script into the Starterpack. (Unsure if this is the problem.) I'm trying to send leaderstats NumberValue "Coins". Purchasing works, but sending the "Coins" won't. Any help on how to fix this?
local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
MarketplaceService.ProcessReceipt = function(receiptInfo)
print("Testing Receipt Loaded")
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 == 19918045 then
print("Did this succeed?")
lds = v:FindFirstChild("leaderstats")
if lds ~= nil then
cs = lds:FindFirstChild("Coins")
if cs ~= nil then
cs.Value = cs.Value + 100
print("Coins Sent")
end
end
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end

1 comment
It works! Thank you!