Can't require module script table

Hello.

So i’m doing a script that clones a model from replicatedstorage.

The script that would clone the model is in server script service and the module script itself is inside the model.

this is the code that is supposed to clone the model:

local instance = game.ReplicatedStorage.Van:Clone()
local modulescript = instance:WaitForChild("ModuleScript")

instance.Parent = game.Workspace

local module = require(modulescript.vanmodule)

module.moveaway()
1 Like

What is not working in the script exactly, and r u sure that the modulescript is the vanmodule one?

1 Like

So the error that it outputs has to do with the require.

It basically says that vanmodule (the table inside modulescript), is not a valid member of the module script itself

2 Likes

can you test what this prints?

print(modulescript:GetDescendants())
2 Likes

It only prints an empty table {}.

I assume there is an error in the module script itself.

1 Like

You can’t require a table from the module, try this:

local instance = game.ReplicatedStorage.Van:Clone()
local modulescript = instance:WaitForChild("ModuleScript")

instance.Parent = game.Workspace

local module = require(modulescript)  -- Corrected this

module.moveaway()
4 Likes

Alright, it seems to work now.

Yeah I’m new with module script usage. It wouldn’t make any sense to require a table, since it returns value anyways.

Thanks for the help, i’ll mark your solution.

2 Likes

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