Scriptクラス

クラス日本語解説あり

ひとことで言うと

サーバー(ゲームを動かすコンピューター)で実行されるスクリプトです。ゲームのルールやデータの保存など、全員に関わる処理を書きます。

公式の説明(英語):An object that contains and runs Luau code on the server.

ServerScriptServiceやWorkspaceの中に置くと動きます。プレイヤー1人ひとりの画面の処理(キー入力など)は、LocalScriptで書きます。

使用例

ふれたプレイヤーを倒すブロック(キルブロック)
Script置く場所:パーツの中
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)

名前と書き方説明
Source
Script.Source: ProtectedString
The code to be executed.

受け継いでいるメンバー

BaseScript から受け継いでいるもの(3)

Disabled・Enabled・RunContext

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)

ClassName・GetPropertyChangedSignal・IsA・Changed

Scriptを使う記事

英語の説明とメンバーの一覧は、Roblox Creator Documentation(Script)をもとにしています(CC BY 4.0)。日本語の解説は、このサイトで独自に書いたものです。

執筆:鈴木孝昌官公庁のWeb・システム開発を担当する現役プロジェクトマネージャー。沖縄マイクラ部 クロスウェーブで、ロブロックス(Roblox)・マインクラフト(マイクラ)・Scratchなどのプログラミングを指導。マイクラカップ沖縄代表チームを指導(第6回・第7回、第7回TBS賞)。
沖縄マイクラ部で、子どもたちにロブロックス(Roblox)やマインクラフト(マイクラ)のプログラミングを教えています。プロフィールと編集方針
Instagramで教室の様子を見る
noteで記事を読む