Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What is RunService, and why do we use and why is it useful?

Hey there, I know what RunService is but I want to know where is RunService used?

Currently when I see RunService it's only events like e.g. Heartbeat. How is that example used in scripting?

1 comment

0

An example of it being useful is on FPS frameworks. I use RenderStepped instead of Heartbeat, and I need RenderStepped so that it can render every single Lerp of the framework.

1 answer

✓ Accepted answer

Technically Heartbeat is useful, but I use other keywords for Heartbeat, that are similar. If you want to know more go to Developer.Roblox and check out RunService and Heartbeat, RunService is basically a long list of stuff that roblox allows you to do and also can check if you're in studio, in game etc. RunService while using : which connects a function to a Variable, RunService.Heartbeat which is an Event, and iit runs on a variable frequency. If the game is running 40 fps the heatbeat will fire 40 times a second and the step argument is 1/40th of a second.

local RunService = game:GetService("RunService")
 
local RATE_PER_SECOND = 2
 
RunService.Heartbeat:Connect(function(step)
	local increment = RATE_PER_SECOND * step
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.