ModuleScript functions returning as nil when called by a server-sided script

I’m trying to write a lighting system for my game using nested tables in a ModuleScript, but every time I try to call the event, the function returns nil, as demonstrated in the below screenshot.
image

These are the tables that’re being referenced. You can see that "ChamberSpotlights.Off" is a function.

When the event is fired, the function module is required and separates a string to index the tables with this function (thanks TheNexusAvenger for helping me figure this part out.)

This leads to the error in the first screenshot.

Neither of us can figure out what’s wrong here so I’m making this post as a last-ditch effort to understand why this error is happening in the first place.

I’d say it’s because your function tries to index Off inside the larger table Functions, not inside ChamberSpotlights

with this return from the module you need to call
Functions.ChamberSpotlights[func]

please never make screenshots of text, insert text instead.
thank you!

The variable On is being set to your anonymous function function() end, which returns nil, you are basically not assigning the keys to functions, youre setting them to the return values of the functions

Try changing the keys from this:

ChamberSpotlights = {
	On = function()
	end,
	Off = function()
	end,
	Blackout = function()
	end,
}

To this:

local function OnF()
	
end

local function OffF()
	
end

local function BlackoutF()
	
end

ChamberSpotlights = {
	On = OnF,
	Off = OffF,
	Blackout = BlackoutF
}