Scriptクラス
ひとことで言うと
サーバー(ゲームを動かすコンピューター)で実行されるスクリプトです。ゲームのルールやデータの保存など、全員に関わる処理を書きます。
公式の説明(英語):An object that contains and runs Luau code on the server.
ServerScriptServiceやWorkspaceの中に置くと動きます。プレイヤー1人ひとりの画面の処理(キー入力など)は、LocalScriptで書きます。
使用例
local part = script.Parent :: BasePart
part.Touched:Connect(function(hit)
local character = hit.Parent
if not character then
return
end
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
if humanoid then
humanoid.Health = 0
end
end)スクリプトは、Luauの型チェック(luau-lsp)で確認しています。
クラスの関係
受け継いでいるクラス:Object → Instance → LuaSourceContainer → BaseScript → Script
このクラスを受け継ぐクラス:LocalScript
プロパティ(1)
| 名前と書き方 | 説明 |
|---|---|
SourceScript.Source: ProtectedString | The code to be executed. |
受け継いでいるメンバー
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)
Scriptを使う記事
英語の説明とメンバーの一覧は、Roblox Creator Documentation(Script)をもとにしています(CC BY 4.0)。日本語の解説は、このサイトで独自に書いたものです。