I have been making a script for buying currency in my game, and it continues to not work. It keeps saying “invalid argument #2 to ‘random’ (interval is empty)”, which is confusing since everything seemed to be working right. Anything helps!
Script:
local MPS = game:GetService("MarketplaceService")
MPS.ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == 1224240820 then
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 100
print("100 coins")
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif receiptInfo.ProductId == 1224241034 then
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 500
print("500 coins")
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif receiptInfo.ProductId == 1224241165 then
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1000
print("1000 coins")
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif receiptInfo.ProductId == 1224241654 then
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 5000
print("5000 coins")
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif receiptInfo.ProductId == 1224241847 then
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 10000
print("10,000 coins")
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif receiptInfo.ProductId == 1224242076 then
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50000
print("50,000 coins")
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end