Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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?

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. Dovydas1118 1495 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

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)
Ad

Answer this question