Calculating how much data is used using datastores?

Hello everyone! I am trying to make a UI element that shows how much data they have used out of their total data (similar to showing how much storage you have on a particular drive).
Example image:
cloud-upload-2
I saw something similar to this one time while playing Welcome to Bloxburg. In settings it shows your plot data size. I feel this is really simple but I cannot figure it out. If anyone has the concept for this, I can go from there. I am not asking for a script.

My question is, how do you compute how much data is used out of the total in a particular key while using datastores.

Thanks!

image
Source: Data Stores

So, you can use this code from picture:
(code untested)

local HttpServ = game:GetService("HttpService")

local DataStore = game:GetService("DataStoreService")

local DataStoreName = DataStore:GetDataStore("DataName")

local dat,err = pcall(function()
   return DataStoreName:GetAsync("key")
)
if dat then
  print(string.len(HttpServ:JSONEncode(dat)))
end
8 Likes

I can’t believe I didn’t see that lol. Thank you, I’ll give this a shot.