Can't call a module function

I’m trying to make a fighting game with a friend of mine, and I created a custom folder in “game” with a module called “Processor” in it.
Every time I try to call this module with a script, I get an error saying:
“ServerScriptService.Server:2: attempt to call a nil value”

Here is the processor code:

local processor = {}

local Classes = script.Parent.Classes
local Assets = script.Parent.Assets
local Modules = script.Parent.Modules
local Attributes = script.Parent.Attributes

local PlayerCall = function()
	game.Players.PlayerAdded:Connect(function(plr)
		plr.CharacterAdded:Connect(function(chr)
			repeat wait() until chr ~= nil
			local screen = Assets.GUI.Title:Clone()
			screen.Parent = plr.PlayerGui
		end)
		plr:LoadCharacter()
	end)
end

processor.Run = function(strng)
	if Attributes.Running.Value == false then
		Attributes.Running.Value = true
		PlayerCall()
	end
end

return processor

And here is the code that calls the processor:

local main = game:WaitForChild("Main_")

local processor = require(main:WaitForChild("Processor"))
processor.Run("")

I looked for topics closest to this, but barely any of these were related to this issue.
Please, if anyone can help, thank you.

The error you’re receiving is quite literally telling you that the asset you’re trying to reference doesn’t exist.

Make sure Assets is in the correct location you’re creating a reference to.

1 Like

Not quite, the error is actually telling him that a function doesn’t exist.

What is line 2? Neither of the scripts you showed me can throw that type of error on line 2. Did you change the spacing? Or is this a different script erroring?

Yup, Im sorry, I think you should be right. Actually, I tested it again. And worked fine… I dont understand why when I deleted the whole functions in module and testing it, still getting an infinite yield when server starts… But right now its not yielding again. So yes, its the module :3

Edit: Oh, I thought you were the original poster saying that you fixed it yourself. I’ll go cry in a corner.

My original post:
Infinite yield? As in infinite yield possible? That would be orange in color, so it would be a warning. It will not stop the code from running, but warnings can indicate certain unexpected behaviors. In this case, it’s telling you that one of the WaitForChilds is taking more than 5 seconds to find the object such as Main_, which is not unusual when the game is first loading.

xD Nope Im not the OP, I was trying to solve their issue, I tested the scripts OP provided and I was getting an infinite yield, Yes, exactly that, it was impossible to find the Processor Module. So I suggested using a loop to find it, and it worked… But, then I tried again by just require(game.Folder.Processor) And works… It didnt worked before and I dont know why. Now works.

1 Like

Can you show us what your explorer looks like?

try being more explicit when defining the function. what i mean is turn this

processor.Run = function(strng)
	if Attributes.Running.Value == false then
		Attributes.Running.Value = true
		PlayerCall()
	end
end

to this

function processor.Run(strng)
	if Attributes.Running.Value == false then
		Attributes.Running.Value = true
		PlayerCall()
	end
end

Isn’t this the problem? because i don’t know what the child of game called Main_
This will cause the require(main:WaitForChild("Processor")) to give an error because main would be nil

Main_ Is a folder that is located inside of the “game” instance.

Explorer
Here is what the explorer looks like.

Actually, wait, I think I fixed it.
I had to re-identify every function inside the processor module.
I returned to the team create session and saw that the “Main_” Folder was gone, so I got a recovery file to put it back where it belongs.

2 Likes

How did you even do that!? like HOW?!

bruh how did you do that ?? :rofl:
29 characterssssss