LocalScriptクラス
ひとことで言うと
プレイヤーそれぞれのコンピューター(クライアント)で実行されるスクリプトです。キー入力・カメラ・画面の表示(GUI)など、その人だけの処理を書きます。
公式の説明(英語):An object that contains and runs Luau code on the client (player's device) instead of the server.
StarterPlayerScripts・StarterCharacterScripts・StarterGuiなどの中に置くと動きます。Workspaceの中に直接置いても動かないので注意しましょう。
使用例
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then
return
end
if input.KeyCode == Enum.KeyCode.E then
print("Eキーが押された")
end
end)スクリプトは、Luauの型チェック(luau-lsp)で確認しています。
クラスの関係
受け継いでいるクラス:Object → Instance → LuaSourceContainer → BaseScript → Script → LocalScript
受け継いでいるメンバー
BaseScript から受け継いでいるもの(3)
Instance から受け継いでいるもの(46)
Archivable・Capabilities・IsInSandbox・Name・Parent・PredictionMode・Sandboxed・AddTag・ClearAllChildren・Clone・Destroy・FindFirstAncestor・FindFirstAncestorOfClass・FindFirstAncestorWhichIsA・FindFirstChild・FindFirstChildOfClass・FindFirstChildWhichIsA・FindFirstDescendant・GetActor・GetAttribute・GetAttributeChangedSignal・GetAttributes・GetChildren・GetDebugId・GetDescendants・GetFullName・GetStyled・GetStyledPropertyChangedSignal・GetTags・HasTag・IsAncestorOf・IsDescendantOf・IsPropertyModified・QueryDescendants・RemoveTag・ResetPropertyToDefault・SetAttribute・WaitForChild・AncestryChanged・AttributeChanged・ChildAdded・ChildRemoved・DescendantAdded・DescendantRemoving・Destroying・StyledPropertiesChanged
Object から受け継いでいるもの(4)
LocalScriptを使う記事
英語の説明とメンバーの一覧は、Roblox Creator Documentation(LocalScript)をもとにしています(CC BY 4.0)。日本語の解説は、このサイトで独自に書いたものです。