How would I go about getting a player’s cpu usage?
There is no way of accessing a player’s CPU usage using Roblox. However I don’t see the benefit of using it anyway.
I would recommend using FPS instead, which is very easy to implement:
workspace:GetRealPhysicsFPS()
I hope I could help. Let me know if this has you covered.
There is no direct or precise way to get a player’s CPU usage. My random guess is that you are trying to spread out a CPU-intensive algorithm across frames (otherwise, there is no much other use of knowing the CPU usage). The easiest way to achieve this is to call Heartbeat:Wait() after a certain amount of time passed.
As an example, in case you want your framerate to stay around 30FPS, you would add this to a loop.
local eventHeartbeat = game:GetService("RunService").Heartbeat
local timeLast = os.clock()
while true do
--your code
if os.clock()-timeLast>(1/30-1/120) then
eventHeartbeat:Wait()
timeLast = os.clock()
end
end
However, you can get the total memory usage of your game with the :GetTotalMemoryUsageMb() method of Stats service. Memory usage is often linked to the CPU usage, so you can use it as an unreliable indicator.