firesignal
Fires a signal with the given arguments.
Syntax
firesignal(signal: RBXScriptSignal, ...: any) -> voidParameters
| Parameter | Type | Description |
|---|---|---|
signal | RBXScriptSignal | The signal to fire |
... | any | Arguments to pass to handlers |
Returns
This function does not return a value.
Description
firesignal triggers all connected handlers of a signal with the provided arguments. This simulates the signal being fired naturally.
Example
-- Fire a button's MouseButton1Click
local button = PlayerGui.ScreenGui.TextButton
firesignal(button.MouseButton1Click)
-- Fire with arguments
firesignal(someObject.CustomEvent, "arg1", 123, true)Firing Input Events
-- Simulate a key press
local UserInputService = game:GetService("UserInputService")
local inputObject = Instance.new("InputObject") -- Pseudocode
firesignal(UserInputService.InputBegan, inputObject, false)Firing Touch Events
local part = workspace.TouchPart
local character = game.Players.LocalPlayer.Character
local hrp = character.HumanoidRootPart
-- Fire the Touched event
firesignal(part.Touched, hrp)Notes
- All connected handlers will be called
- Arguments are passed to each handler
- Use
getconnectionsto fire specific connections only
Related Functions
getconnections- Get signal connectionsreplicatesignal- Fire with replication