What Is RunService?

Hello, :wave:

I’ve been learning about run service and I don’t understand anything. I also found out the events I was learning heartbeat, renderstepped, and stepped were deprecated. I searched the new events presimulation, postsimulation, PreRender and there’s not much documentation of it. So can someone explain what runservice is, when will I use it and how do I use it? Thanks! :wave:

1 Like

According to the wiki, heartbeat, renderstepped, and stepped aren’t deprecated. Look again. Basically, every event fires every frame, renderstepped before rendering, stepped prior to physics but after rendering, and finally heartbeeat after all of that is done.

Like what poke said, You might want to be careful when you are using RS, because if a player is running high-fps on your game it’ll run the script more times, if you are running low fps it’ll run at a lower rate. Which causes major unbalance. There are plenty of articles here on the dev-forum that teach how to do that.

Ok, thanks but when will I use it? And how?

There are quite a few cases in which RunService comes in handy, specifically with the :BindToRenderStep() and :IsStudio() functions.

I would suggest checking the API Page for more information. If you are looking for what cases they are used in, a good example with the :IsStudio() function is to check if the user is running the game in studio and if so you can avoid for example, saving data to a data store for debug purposes, ect.

I suppose you could think of RunService as basically a Test Dummy: It basically tests stuff for you to try

image

There are a couple of cool functions that you can use with RunService, such as:

  • Detecting if the current script ran is in Studio, a Server Script, or a Client Script

  • Firing Events (Stepped, Heartbeat, RenderStepped) that run every frame (Could be useful for FPS detection)

  • Running/Stopping/Pausing the current game’s simulation (Like on Studio’s interface)

Say we want to detect if the current script we’re testing this game on is in Studio:

--We're currently in Studio right now
local RunService = game:GetService("RunService")

if RunService:IsStudio() then
    print("This script detected that the studio is open!")
end

This will print out, since IsStudio() will return back a BoolValue as true!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.