Invalid argument #2 to 'random' (interval is empty)

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

as far as I know the error isn’t in that code
it should show the line and what script the error is located in if you look at the error message in output

It works in studio, but not in the actual game. Is it because I have it in workspace as a normal script instead of a LocalScript?

Localscripts won’t run if they are parented to an instance in the workspace (not counting player’s character) and adding coins with a local script is dangerous thanks to exploiters.

But as far as I know the error is not affecting this piece of code but something else. I’m going to guess it is affecting something related to math.random or something with that kind. For example trying to run this: print(math.random(1,0)) returns the same error.

I also have a top 25 richest leaderboard that does the “player.leaderstats.Coins.Value” part when running. Could that be affecting it?

Update: this has been solved.