Sorry for the late response.
Basics of signal
-- a module script can hold these, so every script can have access to it
local signal = require(game.ReplicatedStorage.Signal) -- change this where your signal module is
local myEvents = {}
myEvents.myCustomEvent = signal.new()
return myEvents
-- then a different module can do
local myEventsModule = require(nil) -- replace this where the module containing all of the signals are
myEventsModule.myCustomEvent:Fire("The chosen number is 5")
-- another script can listen to this custom event now
local myEventsModule = require(nil) -- replace this where the module containing all of the signals are
myEventsModule.myCustomEvent:Connect(function(text)
warn(text)
end)
Disconnect from signals
You can also disconnect from signals
local myConnection = myEventsModule.myCustomEvent:Connect(function(arguments)
print("Hi!")
end)
myConnection:Disconnect()
-- disconnects from every single connection that other scripts made
myConnection:DisconnectAll()
- Then there is deferred fire, what is basically fire, but uses task.defer internally
- Then signal:Wait(), that makes the thread yield (the script that called this function), until the signal gets fired, and returns the arguments from the fire method.
- And finally destroy, that as the name suggests, destroys the class.
I’m 99% sure, that I did not miss out anything. Hope this helped!