Roblox Developer Logo Get Started Learn Roblox API Reference Community



Event of RunService.pngRunService
RBXScriptSignal Heartbeat (
    double step
  1. step

Description: Fires every frame. The step argument indicates how much time has passed between frames. This is usually around 1/60th of a second. Please note that this will vary depending on the performance of the machine. If the game is only running at 40 FPS, that means that Heartbeat will fire 40 times per second, and the step argument will be roughly 1/40th of a second.


The following code would be put in a Script. The script can be placed in the Workspace.

local RunService = game:GetService('RunService')
local loopCount = 5
local count = 0
    if count < loopCount then
        count = count + 1
        print("Time between each loop: "..step)
Time between each loop: 0.016042137518525
Time between each loop: 0.016596353009343
Time between each loop: 0.015978462994099
Time between each loop: 0.015978462994099
Time between each loop: 0.016075769937038