ServerScriptService.GameScript:4: attempt to call a nil value - Server - GameScript:4

I have compared this to my older scripts that use modules and I’m seeing nothing of fault, yet apparently there’s an ‘attempt to call a nil value’

GameLoop.lua

local FireManager = require(script.FireManager)

while true do
	FireManager.test()
end

FireManager.lua (Module Script)

local FireManager = {}

function test ()
	while wait(1) do
		print(1)
	end
end

return FireManager

image

You created the function, but it isn’t in the FireManager table (which means - it isn’t sent to the script)

GameScript:

local FireManager = require(script.FireManager)

while true do
	FireManager.test()
end

FireManager:

local FireManager = {}

function FireManager.test ()
	while wait(1) do
		print(1)
	end
end

return FireManager

Try this

local FireManager = require(script.FireManager)

while task.wait() do
	FireManager.test()
end
----------------------------------------
local FireManager = {}

function FireManager.test()
		print("Hello world!")
end

return FireManager

task.wait() is the better option over wait()
The print() function expects string arguments.

Over task.wait, I agree
HOWEVER:
image
print can accept an Instance, a number, a boolean, etc.
For an Instance it’d print it’s name, the number would get converted in a string (same for a boolean) & printed

First off, never use a while true to create a while wait. What will occur is extensive death to your client/server.

as for the actual code

--GameScript.Lua

local FireManager = require(script:WaitForChild("FireManager"))

while task.wait() do -- while true do isn't the best method anymore
FireManager.Test()
end
--FireManager.Lua

local FireManager = {}

FireManager.Test = function()
       print(1)
end)

return FireManager

Yeah I’m aware, I haven’t heard of task.wait though. I just slammed the while true in there so I could see if the module was being called.

Thanks everyone for the responses!