Issue with ModuleScript giving another ModuleScript a table with functions

Hi, I am trying to create a module script that’s under a main module script that will store functions for its specific purpose, and then add them to the table of the main module script.
My experience trying to do that though has been kind of tough. :sweat_smile:

Here is the main module script.

local Character = {
	
};
Character.__index = Character;
table.insert(Character, 1, require(script.Movement))

Character.New = function()
	local NewCharacter = {};
	setmetatable(NewCharacter, Character);
	return NewCharacter;
end;

return Character;

Here is the movement module script that is under the main one.

local Movement = {};

function Movement:Dash()
	--...
end;

function Movement:Run()
	--...
end;

return Movement;

I haven’t got any script analysis errors, and only get this error once I join game and try using one of the functions from the client script.

local Character = require(game:WaitForChild("ReplicatedStorage").Character).New()
Character.Movement:Dash()


Can I get some help as to what I am doing wrong or a better way to deal with this?

replace the : with . in both the module and the script after the Movement

1 Like


Still doesnt work. Maybe the functions aren’t actually ending up inside of the table?

Movement.Dash = function()

end

try doing something like this in the module

1 Like

The issue is still happening.

The table you’re inserting doesn’t have the index of Movement, it has the index of 1.
Instead of doing
table.insert(Character, 1, require(script.Movement))
try
Character["Movement"] = require(script.Movement)

1 Like

Didn’t know I could do that, thanks!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.