Help with Signals and Maids

Hi! I have come to the devforum for help on how to use NevermoreEngine’s Signals and Maids. This is also my first time posting on here so I am no expert on how to format posts.

I have been attempting to use them for several hours but can’t entirely wrap my head around them and would appreciate some help.

-Script

local TestModule = require(game:GetService("ReplicatedStorage").ModuleScript)

local TestModule = TestModule.new()

wait(1)

TestModule:fireSection()

TestModule.exampleSignal:Connect(function()
	print("Worked!")
end)

-Module

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Vendors = ReplicatedStorage.Vendors
local Signal = require(Vendors.Signal)
local Maid = require(Vendors.Maid)

local TestModule = {}
TestModule.__index = TestModule

--CONSTRUCTOR
function TestModule.new()
	local self = {}
	setmetatable(self, TestModule)
	
	local maid = Maid.new()
	self.exampleSignal = maid:GiveTask(Signal.new())
	
	return self
end

--METHODS
function TestModule:fireSection()
	self.exampleSignal:Fire() --Erroring Line
end

return TestModule

Upon running this I get the error: ReplicatedStorage.ModuleScript:22: attempt to index number with ‘Fire’.

1 Like

Figured out what was wrong, might as well show how to fix this if someone ever comes across a similar issue.

1st of all, TestModule:fireSection() has to run after the connect function. The 2nd issue was me incorrectly setting up the maid which ran the signal.

Instead of doing

local maid = Maid.new()
self.exampleSignal = maid:GiveTask(Signal.new())

You should do

local maid = Maid.new()
self._maid = maid --You might be able to do self._maid = Maid.new but I prefer it this way

self.exampleSignal = Signal.new()
self._maid:GiveTask(self.exampleSignal)
2 Likes