So im making a donation board and when i hopped onto my alt to test it if it works and i tried buying a product and it says the error below but it works perfectly fine on my main like i can buy the products but as soon as i switch to an alt and try buying the developer product and it says this
Error handling 1326743796's purchase: 103: string is not allowed in data stores.
a friend said make userid an increment of purchased quantity rather dictionary of ids purchased or increment the actual value check what donatedamount and previous data is it says the issue is string But ur trying to use + for numbers
I explain what previousData & donatedAmount are previousData - is used for getting the players whole total of how much robux they've donated in the game so for example the player has bought 150 robux in total.
donatedAmount - is used for how much robux the player has bought so for example the player only bought the product for 5 robux.
also its weird because on my main the purchases complete but when im on my alt it says the error just very confusing on why the error only pops up when im on an alt also im pretty sure it happens to other players as well?
local function processReceipt(receiptInfo)
local donatedAmount = findAmountById(receiptInfo.ProductId)
local id = receiptInfo.PlayerId
local success, err = pcall(function()
donations:UpdateAsync(id, function(previousData)
if previousData then
return previousData + donatedAmount
else
return donatedAmount
end
end)
end)
local player = Players:GetPlayerByUserId(id)
if not success then
if player then
eve:FireClient(player, "Error", "There was an error processing your purchase. Error: " .. err)
end
warn("Error handling " .. id .. "'s purchase: " .. err)
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if player then
eve:FireClient(player, "Success", "Thanks for your generous donation!")
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
I need to fix this but i cant do it rn but the error keeps happening here i think its has to do something with the local id? but im not sure
well the thing thats being saved is the player purchase so it logs how much the player has spent / total of robux that has been donated so i have
previousData - is used for getting the players whole total of how much robux they've donated in the game so for example the player has bought 150 robux in total.
donatedAmount - is used for how much robux the player has bought so for example the player only bought the product for 5 robux.
You need to share line 103 and/or the code around it as that is what’s throwing/raising an error. Make sure the value which the variable “donatedAmount” stores isn’t a string value.
Also sorry for the late reply i just woke up from my nap
OutPut previousData = number & donatedAmount = string
But im a bit confused on how this works perfectly fine on my main account like i can use the donation board without any problems but i went to test it on my alt account then the errors starting popping up so i was a bit confused lol.
Right, that means you’re trying to perform an arithmetic operation on a number and a string. Coerce the string value “donatedAmount” into a number value by wrapping it inside a call to the global function “tonumber()” then perform the arithmetic operation on the two number values before storing the result inside the DataStore.
Oh alright so the function is there because it can get called then sent into the data store but how would i fix this issue?
do i just not make a function for the previousData & donatedAmount
and then once they do their thing i can make a function saving the data to the datastore?
or tell me what you think i should do to fix this?