SHARE
TWEET

Untitled

OverHash Nov 15th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local signalTemplate = {}
  2.  
  3. function signalTemplate:connect(callback)
  4.     local event = self.event.Event:connect(callback)
  5.    
  6.     table.insert(self.connections, event)
  7.    
  8.     return event
  9. end
  10.  
  11. function signalTemplate:disconnect()
  12.     for connectionIndex=1,#self.connections do
  13.         self.connections[connectionIndex]:disconnect()
  14.     end
  15. end
  16.  
  17. function signalTemplate:wait()
  18.     return self.event.Event:wait()
  19. end
  20.  
  21. function signalTemplate:fire(...)
  22.     self.event:Fire(...)
  23. end
  24.  
  25. local signalMetatable = {
  26.     __index = signalTemplate
  27. }
  28.  
  29. local function CreateSignal()
  30.     local signal = {}
  31.    
  32.     signal.event = Instance.new("BindableEvent")
  33.     signal.connections = {}
  34.     setmetatable(signal, signalMetatable)
  35.    
  36.     return signal
  37. end
  38.  
  39. return {CreateSignal = CreateSignal}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top