# RunService(ロブロックス クラス) > ゲームの1フレームごとに処理を実行するためのサービスです。パーツを回し続けるなど、なめらかに動かし続けたいときに使います。 - URL:https://roblox.minecraft-okinawa.com/reference/classes/RunService/ - 公式:https://create.roblox.com/docs/reference/engine/classes/RunService - 受け継いでいるクラス:Instance ## 使用例:回り続けるパーツ (Script/置く場所:パーツの中) ```lua local RunService = game:GetService("RunService") local part = script.Parent :: BasePart part.Anchored = true RunService.Heartbeat:Connect(function(deltaTime) part.CFrame = part.CFrame * CFrame.Angles(0, math.rad(90) * deltaTime, 0) end) ``` ## プロパティ - `RunService.RunState: RunState`:The current run state of the game's simulation. ## メソッド - `RunService:BindToAnimation(function: Function, frequency: StepFrequency, priority: int): RBXScriptConnection`:Binds a custom function to be called at a fixed frequency before Animators update when fixed simulation is enabled, or immediately before BindToSimulation callbacks otherwise. - `RunService:BindToAnimationParallel(function: Function, frequency: StepFrequency, priority: int): RBXScriptConnection`:Binds an Actor-scoped function to run in parallel at a fixed frequency after serial Class.RunService:BindToAnimation()|BindToAnimation() callbacks. - `RunService:BindToRenderStep(name: string, priority: int, function: Function): ()`:Given a string name of a function and a priority, this method binds the function to RunService.PreRender. - `RunService:BindToSimulation(function: Function, frequency: StepFrequency, priority: int): RBXScriptConnection`:Binds a custom function to be called at a fixed frequency which is independent of the frame rate. - `RunService:BindToSimulationParallel(function: Function, frequency: StepFrequency, priority: int): RBXScriptConnection`:Binds an Actor-scoped function to run in parallel at a fixed frequency after serial Class.RunService:BindToSimulation()|BindToSimulation() callbacks. - `RunService:GetPredictionStatus(context: Instance): PredictionStatus`:Checks the PredictionStatus of a specific context instance, useful for debugging scripts affecting multiple instances where some might be predicted and others might not. - `RunService:IsClient(): boolean`:クライアントで実行されているかを調べます。 - `RunService:IsEdit(): boolean`:Returns whether the current environment is in Edit mode. - `RunService:IsResimulating(): boolean`:Returns whether the client is currently in a resimulation step after a misprediction in the server authority model. - `RunService:IsRunMode(): boolean`:Returns whether a **Run** playtest has been initiated in Studio. - `RunService:IsRunning(): boolean`:Returns whether the experience is currently running. - `RunService:IsServer(): boolean`:サーバーで実行されているかを調べます。 - `RunService:IsStudio(): boolean`:Returns whether the current environment is running in Studio. - `RunService:Pause(): ()`:Pauses the experience's simulation if it is running, suspending physics and scripts. - `RunService:Run(): ()`:Runs the game's simulation, running physics and scripts. - `RunService:SetPredictionMode(context: Instance, mode: PredictionMode): ()`:Sets the prediction mode for an Instance to an PredictionMode value. - `RunService:Stop(): ()`:Stops the experience's simulation if it is running. - `RunService:UnbindFromRenderStep(name: string): ()`:Unbinds a function that was bound to the render loop using Class.RunService:BindToRenderStep(). ## イベント - `RunService.Heartbeat(deltaTime: double)`:毎フレーム、物理の計算のあとに発生するイベントです。前のフレームからの経過時間(秒)が渡されます。 - `RunService.Misprediction(time: double, instances: Array, stats: Dictionary)`:In the server authority model, fires during prediction when the engine detects that the client has diverged from the server's authoritative state. Intended for plugin-based debugging. - `RunService.PostSimulation(deltaTimeSim: double)`:Fires every frame, after the physics simulation has completed. - `RunService.PreAnimation(deltaTimeSim: double)`:Fires every frame, prior to the physics simulation but after rendering. - `RunService.PreRender(deltaTimeRender: double)`:Fires every frame, prior to the frame being rendered. - `RunService.PreSimulation(deltaTimeSim: double)`:Fires every frame, prior to the physics simulation. - `RunService.RenderStepped(deltaTime: double)`:毎フレーム、画面を描く前に発生するイベントです(LocalScript専用)。 - `RunService.Rollback(time: double)`:In the server authority model, this fires after rolling back the predicted state due to a misprediction, but before resimulation begins. - `RunService.Stepped(time: double, deltaTime: double)`:Fires every frame, prior to the physics simulation. 英語の説明とメンバー一覧:Roblox Creator Documentation(CC BY 4.0)。日本語の解説はこのサイト独自のものです。 執筆:鈴木孝昌(現役プロジェクトマネージャー/プログラミング講師)/運営:沖縄マイクラ部 プログラミングスクール「クロスウェーブ」(https://minecraft-okinawa.com/)