RunService

RunService : Instance

Properties

ClientGitHash

string

{Description Slot}

Code Samples

Methods

IsClient

The IsClient method checks if the current execution context is running on a client.

Parameters

Return

bool

Code Samples

local RunService = game:GetService("RunService")

local IsClient = RunService:IsClient()
print("IsClient : ", IsClient)

IsServer

The IsServer method checks if the current execution context is running on server.

Parameters

Return

bool

Code Samples

local RunService = game:GetService("RunService")

local IsServer = RunService:IsServer()
print("IsServer : ", IsServer)

IsStudio

The IsStudio method checks if the current execution context is running in OVERDARE Studio. This is useful for debugging purposes or when specific actions should only occur during testing in Studio, and not in live gameplay.

Parameters

Return

bool

Code Samples

local RunService = game:GetService("RunService")

local IsStudio = RunService:IsStudio()
print("IsStudio : ", IsStudio)

Events

Heartbeat

The Heartbeat event fires after the physics simulation step and before the frame is rendered. It is commonly used for tasks that need to run every frame after physics calculations are complete, such as applying the results of physics simulations or performing game logic updates that should precede rendering.

Example uses include updating non-physics game mechanics, animating game objects, or performing real-time computations that depend on the latest state of the game's physics engine.

Parameters

Code Samples

local RunService = game:GetService("RunService")
local Timer = 0

local function UpdateEvent(deltaTime)
    Timer = Timer + deltaTime
    print(Timer)
end
RunService.Heartbeat:Connect(UpdateEvent)

Stepped

The Stepped event fires before the physics simulation step on both the client and the server. It is typically used for tasks that need to occur before physics calculations, such as preparing game state or performing updates that should influence the upcoming physics simulation.

This event can be useful for precise control over pre-physics updates or when synchronizing gameplay systems with the physics step.

Example uses include implementing custom movement logic, updating forces applied to physics objects, or adjusting player inputs before physics calculations begin.

Parameters

Code Samples

local RunService = game:GetService("RunService")

local function OnStepped(timeElapsed, deltaTime)
    print(timeElapsed)
end
RunService.Stepped:Connect(OnStepped)

RenderStepped

The RenderStepped event fires before the frame is rendered on the client. It is primarily used for tasks that need to run every frame and are specific to the rendering process, such as updating the camera's position, animating UI elements, or making visual adjustments to the game's appearance.

By using RenderStepped, developers can ensure that updates occur just before rendering, ensuring smoother visuals and better synchronization with the frame rate. It is worth noting that this event only fires on the client and is not available on the server.

Parameters

Code Samples

local RunService = game:GetService("RunService")
local Timer = 0

local function OnRenderStepped(deltaTime)
    Timer = Timer + deltaTime
    print(Timer)
end
RunService.RenderStepped:Connect(OnRenderStepped)

Last updated