RunService

RunService : Instance

Overview

RunService๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ํ”„๋ ˆ์ž„ ๋‹จ์œ„์˜ ๋ฐ˜๋ณต ๋ฃจํ”„ ์ด๋ฒคํŠธ๋ฅผ ํ™œ์šฉํ•ด ๋กœ์ง์„ ์ฒ˜๋ฆฌํ•˜๊ฑฐ๋‚˜, ํ˜„์žฌ ์‹คํ–‰ ์ค‘์ธ ํ™˜๊ฒฝ์ด ์„œ๋ฒ„์ธ์ง€ ์ŠคํŠœ๋””์˜ค์ธ์ง€ ๋“ฑ์„ ํŒ๋ณ„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์‹คํ–‰ ํ™˜๊ฒฝ์„ ํ™•์ธํ•˜๋Š” ๊ธฐ๋Šฅ์€ ํŠนํžˆ ํด๋ผ์ด์–ธํŠธ์™€ ์„œ๋ฒ„ ์–‘์ชฝ์—์„œ ๊ณต์œ ๋˜๋Š” ModuleScript์—์„œ ํ™˜๊ฒฝ์— ๋”ฐ๋ผ ๋‹ค๋ฅธ ๋™์ž‘์„ ๊ตฌํ˜„ํ•ด์•ผ ํ•  ๋•Œ ์œ ์šฉํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Properties

ClientGitHash

string

ํ˜„์žฌ ์ง€์›๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

Code Samples

Methods

IsClient

๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•œ ์ฝ”๋“œ๊ฐ€ ํด๋ผ์ด์–ธํŠธ ํ™˜๊ฒฝ์—์„œ ์‹คํ–‰ ์ค‘์ธ์ง€ ์—ฌ๋ถ€๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

LocalScript ๋˜๋Š” LocalScript์— ์˜ํ•ด ๋กœ๋“œ๋œ ModuleScript์—์„œ ํ˜ธ์ถœ๋œ ๊ฒฝ์šฐ, true๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

Parameters

Return

bool

ํด๋ผ์ด์–ธํŠธ ํ™˜๊ฒฝ์—์„œ ์‹คํ–‰ ์ค‘์ธ์ง€ ์—ฌ๋ถ€์ž…๋‹ˆ๋‹ค.

Code Samples

local RunService = game:GetService("RunService")

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

IsServer

๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•œ ์ฝ”๋“œ๊ฐ€ ์„œ๋ฒ„ ํ™˜๊ฒฝ์—์„œ ์‹คํ–‰ ์ค‘์ธ์ง€ ์—ฌ๋ถ€๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

์„œ๋ฒ„ ์ธก์˜ Script ๋˜๋Š” Script์— ์˜ํ•ด ๋กœ๋“œ๋œ ModuleScript์—์„œ ํ˜ธ์ถœ๋œ ๊ฒฝ์šฐ, true๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

Parameters

Return

bool

์„œ๋ฒ„ ํ™˜๊ฒฝ์—์„œ ์‹คํ–‰ ์ค‘์ธ์ง€ ์—ฌ๋ถ€์ž…๋‹ˆ๋‹ค.

Code Samples

local RunService = game:GetService("RunService")

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

IsStudio

ํ˜„์žฌ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์ŠคํŠœ๋””์˜ค ํ™˜๊ฒฝ์—์„œ ์‹คํ–‰ ์ค‘์ธ์ง€ ์—ฌ๋ถ€๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

Studio์—์„œ๋งŒ ๋™์ž‘ํ•ด์•ผ ํ•˜๋Š” ํ…Œ์ŠคํŠธ์šฉ ์ฝ”๋“œ๋ฅผ ์กฐ๊ฑด๋ถ€๋กœ ์‹คํ–‰ํ•  ๋•Œ ์œ ์šฉํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Parameters

Return

bool

์ŠคํŠœ๋””์˜ค ํ™˜๊ฒฝ์—์„œ ์‹คํ–‰ ์ค‘์ธ์ง€ ์—ฌ๋ถ€์ž…๋‹ˆ๋‹ค.

Code Samples

local RunService = game:GetService("RunService")

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

Events

Heartbeat

๋ฌผ๋ฆฌ ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ์™„๋ฃŒ๋œ ํ›„์—, ๋งค ํ”„๋ ˆ์ž„์˜ ๋งˆ์ง€๋ง‰ ๋‹จ๊ณ„ ๋งˆ๋‹ค ํ˜ธ์ถœ๋˜๋Š” ์ด๋ฒคํŠธ์ž…๋‹ˆ๋‹ค.

์Šคํฌ๋ฆฝํŠธ์˜์ผ๋ฐ˜์ ์ธ ์‹คํ–‰ ์‹œ์ ์œผ๋กœ, task.delay๋‚˜ task.spawn ๋“ฑ์„ ํ†ตํ•ด ์˜ˆ์•ฝ๋œ ์Šคํฌ๋ฆฝํŠธ๋„ ์ด ์‹œ์ ์— ํ•จ๊ป˜ ์ฒ˜๋ฆฌ๋ฉ๋‹ˆ๋‹ค.

์ฒด๋ ฅ ํšŒ๋ณต์ด๋‚˜ ํƒ€์ด๋จธ ๊ฐฑ์‹ ์ฒ˜๋Ÿผ ์ฃผ๊ธฐ์ ์œผ๋กœ ์‹คํ–‰ํ•ด์•ผ ํ•˜๋Š” ๋กœ์ง์— ์ ํ•ฉํ•œ ์ด๋ฒคํŠธ์ž…๋‹ˆ๋‹ค.

Parameters

number deltaTime

์ง์ „ ํ”„๋ ˆ์ž„๋ถ€ํ„ฐ ํ˜„์žฌ ํ”„๋ ˆ์ž„๊นŒ์ง€ ํ๋ฅธ ์‹œ๊ฐ„์œผ๋กœ, ๋‹จ์œ„๋Š” ์ดˆ์ž…๋‹ˆ๋‹ค. ํ”„๋ ˆ์ž„ ๊ฐ„ ์‹œ๊ฐ„ ๊ฐ„๊ฒฉ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•œ ๊ณ„์‚ฐ์— ํ™œ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

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

๋ฌผ๋ฆฌ ์‹œ๋ฎฌ๋ ˆ์ด์…˜์ด ์‹œ์ž‘๋˜๊ธฐ ์ „์—, ๋งค ํ”„๋ ˆ์ž„ ๋งˆ๋‹ค ํ˜ธ์ถœ๋˜๋Š” ์ด๋ฒคํŠธ์ž…๋‹ˆ๋‹ค.

Parameters

number time

RunService๊ฐ€ ์‹œ์ž‘๋œ ์ดํ›„ ๊ฒฝ๊ณผ๋œ ์‹œ๊ฐ„์œผ๋กœ, ๋‹จ์œ„๋Š” ์ดˆ์ž…๋‹ˆ๋‹ค.

number deltaTime

์ง์ „ ํ”„๋ ˆ์ž„๋ถ€ํ„ฐ ํ˜„์žฌ ํ”„๋ ˆ์ž„๊นŒ์ง€ ํ๋ฅธ ์‹œ๊ฐ„์œผ๋กœ, ๋‹จ์œ„๋Š” ์ดˆ์ž…๋‹ˆ๋‹ค. ํ”„๋ ˆ์ž„ ๊ฐ„ ์‹œ๊ฐ„ ๊ฐ„๊ฒฉ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•œ ๊ณ„์‚ฐ์— ํ™œ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Code Samples

local RunService = game:GetService("RunService")

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

RenderStepped

ํ™”๋ฉด์— ํ”„๋ ˆ์ž„์ด ๊ทธ๋ ค์ง€๊ธฐ ์ „์—, ๋งค ํ”„๋ ˆ์ž„ ๋งˆ๋‹ค ํ˜ธ์ถœ๋˜๋Š” ์ด๋ฒคํŠธ์ž…๋‹ˆ๋‹ค.

Parameters

number deltaTime

์ง์ „ ํ”„๋ ˆ์ž„๋ถ€ํ„ฐ ํ˜„์žฌ ํ”„๋ ˆ์ž„๊นŒ์ง€ ํ๋ฅธ ์‹œ๊ฐ„์œผ๋กœ, ๋‹จ์œ„๋Š” ์ดˆ์ž…๋‹ˆ๋‹ค. ํ”„๋ ˆ์ž„ ๊ฐ„ ์‹œ๊ฐ„ ๊ฐ„๊ฒฉ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•œ ๊ณ„์‚ฐ์— ํ™œ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

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