ScriptSignal
A class which holds data and methods for ScriptSignals.
Functions
new
Creates a ScriptSignal object.
Is
ScriptSignal.
Is
(
object:
any
) →
boolean
Returns a boolean determining if the object is a ScriptSignal.
local janitor = Janitor.new()
local signal = ScriptSignal.new()
ScriptSignal.Is(signal) -> true
ScriptSignal.Is(janitor) -> false
IsActive
ScriptSignal:
IsActive
(
) →
boolean
Returns a boolean which determines if a ScriptSignal object is active.
ScriptSignal:IsActive() -> true
ScriptSignal:Destroy()
ScriptSignal:IsActive() -> false
Connect
Connects a handler to a ScriptSignal object.
ScriptSignal:Connect(function(text)
print(text)
end)
ScriptSignal:Fire("Something")
ScriptSignal:Fire("Something else")
-- "Something" and then "Something else" are printed
Once
Connects a handler to a ScriptSignal object, but only allows that
connection to run once. Any :Fire
calls called afterwards won't trigger anything.
ScriptSignal:Once(function()
print("Connection fired")
end)
ScriptSignal:Fire()
ScriptSignal:Fire()
-- "Connection fired" is only fired once
Wait
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsScriptSignal:
Wait
(
) →
...any
Yields the thread until a :Fire
call occurs, returns what the signal was fired with.
task.spawn(function()
print(
ScriptSignal:Wait()
)
end)
ScriptSignal:Fire("Arg", nil, 1, 2, 3, nil)
-- "Arg", nil, 1, 2, 3, nil are printed
Fire
ScriptSignal:
Fire
(
...:
any
) →
(
)
Fires a ScriptSignal object with the arguments passed.
ScriptSignal:Connect(function(text)
print(text)
end)
ScriptSignal:Fire("Some Text...")
-- "Some Text..." is printed twice
DisconnectAll
ScriptSignal:
DisconnectAll
(
) →
(
)
Disconnects all connections from a ScriptSignal object without making it unusable.
local connection = ScriptSignal:Connect(function() end)
connection.Connected -> true
ScriptSignal:DisconnectAll()
connection.Connected -> false
Destroy
ScriptSignal:
Destroy
(
) →
(
)
Destroys a ScriptSignal object, disconnecting all connections and making it unusable.
ScriptSignal:Destroy()
local connection = ScriptSignal:Connect(function() end)
connection.Connected -> false