Signal APIs
Functions
getconnections
table getconnections(signal: ScriptSignal, context?: integer)
Returns a script signal's connections.
NOTE: Some events, such as UserInputService
's InputBegan
, actually consist of different signals internally for different security contexts. By default,
getconnections
returns the connections of all signals.
firesignal
void firesignal(signal: ScriptSignal, ...any)
Fires a signal's Lua connections (excluding CoreScript connections). Roughly equivalent to lua for i, v in pairs(getconnections(signal)) do local f = v.Function if f then task.spawn(f, ...) end end
cfiresignal
void cfiresignal(signal: ScriptSignal, ...any)
Fires a signal, including all engine (C) and CoreScript connections. This function cannot be called on "pseudo" signals such as those returned by GetPropertyChangedSignal
. Passed values must be of the correct type.
replicatesignal
void replicatesignal(signal: ScriptSignal, ...any)
Fires a signal on the server. Signal must be replicable.
cansignalreplicate
bool cansignalreplicate(signal: ScriptSignal)
Returns true if a signal can be replicated to the server (see replicatesignal).
getsignalarguments
table getsignalarguments(signal: ScriptSignal)
Returns a table of a signal's arguments' types. For example, passing Instance.AncestryChanged
would return { "Instance", "Instance "}
.
isconnectionenabled
bool isconnectionenabled(connection: ScriptConnection)
Returns true if a connection is enabled.
setconnectionenabled
void setconnectionenabled(connection: ScriptConnection, enable: bool)
Enables or disables a connection. Disabled connections remain connected, but do nothing when fired.
isluaconnection
bool isluaconnection(connection: ScriptConnection)
Returns true if connection
represents a Lua connection.
iswaitingconnection
bool iswaitingconnection(connection: ScriptConnection)
Returns true if connection
is the result of a :Wait()
call.
getconnectionfunction
any getconnectionfunction(connection: ScriptConnection, return_raw?: bool = False)
Returns a connection's associated function. The connection must be a non-waiting Lua connection.
NOTE; Arbitrary values can be passed to .Connect
.
In order to prevent accidental mishaps, this function will, by default, filter out any connected value that is not a function or a table with a __call
metamethod.
If .Connect
was passed table with a __call
metamethod, the returned value will be the value of that metamethod, or nil if that value is not a function.
The optional second parameter will disable this behavior, and will just return whatever was passed to .Connect.
getconnectionthread
thread getconnectionthread(connection: ScriptConnection)
Returns a connection's associated thread. The connection must be a Lua connection.
isgamescriptconnection
bool isgamescriptconnection(connection: ScriptConnection)
Returns true if connection
represents a Lua connection created by game scripts (as opposed to core scripts).