Issue with DataStoreService?

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.

This is the code that was used


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.

3 Likes

What is in line 103? The error is caused in that line.

The error is not about the script line,its about an issue in data store

You can only save UTF-8 characters in a data store, if your trying to save an instance or any non-UTF-8 characters then you get the error

Capture
Might be because im doing this

Nope if you use warn it does not break the script or ruin it, and warn function is no relation to data store issue

actually never mind then what do i do to fix the issue?

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?

I think the issue could be


where i circled i really have no clue

Send me your full script so I can maybe fix

What’s the thing that’s being saved?

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.

1 Like

the error 103 isnt a line its a datastore error like what @Deadwoodx posted

Try print(type(previousData)) and print(type(donatedAmount)) to determine their value types.

2 Likes

You should use typeof, type doesn’t contain some of Roblox’s own data types and just says “userdata” sometimes.

The warning displays that the issue is regarding a string value so type in this instance would be more favorable.

Also sorry for the late reply i just woke up from my nap :sleeping:
Capture

OutPut
Capture
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?