RBXScriptSignalデータ型
データ型日本語解説あり
ひとことで言うと
イベントを表すデータ型です。Connectで関数をつなぐと、イベントが起きたときにその関数が実行されます。
公式の説明(英語):An object that runs connected functions upon a specific occurrence.
使用例
Script置く場所:パーツの中
local part = script.Parent :: BasePart
local connection
connection = part.Touched:Connect(function(hit: BasePart)
print(hit.Name .. " がふれた")
connection:Disconnect()
end)スクリプトは、Luauの型チェック(luau-lsp)で確認しています。
メソッド(4)
| 名前と書き方 | 説明 |
|---|---|
ConnectRBXScriptSignal:Connect(func: function): RBXScriptConnection | イベントに関数をつなぎます。戻り値(RBXScriptConnection)でつなぎを切れます。Connects the given function to the event and returns an RBXScriptConnection that represents it. |
ConnectParallelRBXScriptSignal:ConnectParallel(func: function): RBXScriptConnection | Connects the given function to the event and returns an RBXScriptConnection that represents it. |
OnceRBXScriptSignal:Once(func: function): RBXScriptConnection | イベントが1回起きたら、自動でつなぎを切ります。Connects the given function to the event (for a single invocation) and returns an RBXScriptConnection that represents it. |
WaitRBXScriptSignal:Wait(): Variant | イベントが起きるまで待ちます。Yields the current thread until the signal fires and returns the arguments provided by the signal. |
RBXScriptSignalを使う記事
英語の説明とメンバーの一覧は、Roblox Creator Documentation(RBXScriptSignal)をもとにしています(CC BY 4.0)。日本語の解説は、このサイトで独自に書いたものです。