HELP NEEDED: attempt to perform arithmetic (add) on number and nil

Hello, i was working on re using an old script for a fund raiser and i got an error and i dont know how to fix it

Error: attempt to perform arithmetic (add) on number and nil

local function processReceipt(receiptInfo)
	local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
	local productId = receiptInfo.ProductId
	local donationAmount = robuxDonationIDs[tostring(productId)]
	
	if not player then
		--The player probably left
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	
	if player then
		local currencySpent = receiptInfo.CurrencySpent
		game.ReplicatedStorage.RobuxRaised.Value = game.ReplicatedStorage.RobuxRaised.Value + donationAmount
		print("donation detected")
		RobuxRaisedDataStore.RaiseRobuxAmount(donationAmount)
		print("Amount of Robux raised " .. RobuxRaisedDataStore.GetAsync())
	end

	return Enum.ProductPurchaseDecision.PurchaseGranted
end

Turn the variable donationAmount into a tonumber, it might give a line error but thats ok

And does robuxdonationids have a valid path or table

This error means that you’re trying to add number with nil, the problem is right here:

game.ReplicatedStorage.RobuxRaised.Value = game.ReplicatedStorage.RobuxRaised.Value + donationAmount

You need to make sure donationAmount is not nil, try some sanity checks like:

if donationAmount ~= nil then
    game.ReplicatedStorage.RobuxRaised.Value = game.ReplicatedStorage.RobuxRaised.Value + donationAmount
end

If the error is not fixed, try rechecking your code in case you missed something.
Have a nice day!

yes, robux id’s have a valid value and it didn’t work

try printing donationAmount and show us what it says

its says that its nil, sorry i need to have 30

seems like you casted a string, try this

local donationAmount = robuxDonationIDs[tonumber(productId)]