Get Performance Stats ClientMemoryUsage

Hello Developers!
I am making a model that it is a custom console, I’m trying to get the ClientMemoryUsage but i keep getting a invalid argument #3 (string expected, got Instance) error.

The code that I’m using is:

local StatisticService = game:GetService("Stats")

while wait(0.1) do
	script.Parent.Topbar.ClientMemoryUsage.Text = StatisticService.PerformanceStats.Memory
end

Thank you so much for the help! i appreciate it :grinning:. Im really not sure if i could get Client Memory Usage, but i think some of the people here at the devforum knows. or its really not allowed.

1 Like

It seems like you are trying to access how much memory you are using right now through this, but there seems to be a better way:

StatisticService:GetTotalMemoryUsageMb()

What GetTotalMemoryUsageMb() does is returning how much MegaBytes of Ram is being used by Roblox at that time. API Reference Link: Stats | Roblox Creator Documentation
I think that you can integrate the above very easily in your code you provided.

it works! pretty much Thanks! but can you remove the decimal and just make it a integer?

I’m not so good at math when it comes to coding, I’m not stupid and understand what a Decimal is, but I don’t really know how to modify it in code. Let me try real quick please.

decimal is like this: 0.1
and
integer is like this 1.
Note: Decimal has points(dot) but integer doesn’t

Yep, I know.
Anyways, here is the code:

local StatisticsService = game:GetService("Stats")

while wait(0.1) do
	local MBwithDecimal = StatisticsService:GetTotalMemoryUsageMb()
	local MBwithDecimalNumber = tonumber(MBwithDecimal)
	local MBwithoutDecimal = math.floor(MBwithDecimalNumber + 0.5)
	print(MBwithoutDecimal)
end

The code is very hacky-wacky and Spaghetti, and I can’t do much about that, but it works luckily. I tried to make it so that it says 2000MB and not just 2000, but I just couldn’t make that to work

Since this is probarly the answer, consider marking it as answer for people in the future for easier navigation

Im not on computer currently but I’ll try it tomorrow! Thanks for the help, i appreciate it :grin:

1 Like