How to check amount of characters in a table

just like the title says, i want to check how many characters/string in a table because each datastore key can only hold about 4m characters in a table, so i wanna know how to get the total amount of characters before i need to switch to another table

My guess is that you could use a for loop to loop trough it like so:

local HTTPS = game:GetService("HTTPSService") -- HTTPS service
local table = yourtable -- put your table here
local readableTable = HTTPS:JsonEncode(table) -- Encodes the table so we can read it as a string, this is what roblox automatically does when you save to a datastore
local characters = #string.split(readableTable,"") -- splits the string up into an array, we use the # at the beginning to get the length of the array

Note that I probably made some spelling errors so make sure to fact check em.

thanks, il do that to avoid overflowing each datastore key

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.