Hand-written by Joseph San Nicolas, Roblox Developer
RBXScriptSignal
Constructors
| Name | Description |
| An Instance's built-in event property, e.g. BasePart.Touched or Players.PlayerAdded | Not created by calling a constructor - an RBXScriptSignal is exposed as a built-in event property on an Instance. RBXScriptSignal has no direct constructor of its own. |
Code Snippet
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
print(player.Name, "joined the game")
end)
local hitSignal: RBXScriptSignal = workspace.Part.Touched
hitSignal:Once(function(hit)
print("First touch by", hit.Name)
end)
Methods
| Name | Parameters | Returns | Description |
| Connect(func: function):RBXScriptConnection | Func: function | RBXScriptConnection | Establishes a function to be called whenever the event fires. Returns an RBXScriptConnection that can be used to stop listening. |
| ConnectParallel(func: function):RBXScriptConnection | Func: function | RBXScriptConnection | Establishes a callback that runs in a desynchronized state when the event fires, letting it run in parallel across multiple cores. Requires the calling script to be rooted under an Actor. More efficient than pairing Connect() with task.desynchronize(). |
| Once(func: function):RBXScriptConnection | Func: function | RBXScriptConnection | Establishes a function to be called only the next time the event fires, automatically disconnecting itself right after that first call. |
| Wait():Variant | Void | The arguments passed by the signal, as a tuple | Yields the current thread until the signal next fires, then resumes it and returns whatever arguments the event passed along. |