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

How does Heartbeat work and how would I use it?

How does Heartbeat work exactly and how would I use it? I've been trying to figure out how to use it for a while now, and it's only been working in studio. Can anyone give me a quick run through?

game:GetService("RunService").Heartbeat:connect(function()
	--Script here
end)

I've been treating it as if it were just a loop. Like this:

while true do
	--Script here
end

No matter what I do 'Heartbeat' just doesnt work. Only in studio.

1 answer

RunService is what literally keeps time for games; making you jump to place when you stop lagging and must be viewed from a local script in the client not the server. Heartbeat is the FPS essentially. Frames per second. It fires every time your computer attempts to update its screen. If you are looking for a more trustworthy loop that doesn't change depending on lag, use Stepped

3 comments

1

I didn't learn anything from this, but UpVoted

0

Can stepped be used in a server-script?

0

Both Heartbeat and Stepped can be used in a normal script. As mentioned above, only RenderStepped requires a local script for it to run.

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