Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Am I doing something wrong with this ModuleScript?

I am trying to experiment with ModuleScript's, I'm trying to make it print the name of every-thing in TestFolder but so far I am having problem's with this script. Can anyone tell me what I am doing wrong?

Server Script code:

script.Parent.MouseButton1Click:connect(function()
	local module = game.ReplicatedStorage.Modules.TestingModule
	module:GetChildren()
end)

ModuleScript code:

local module = {}

function module:GetChildren()
	for i,v in pairs(game.ReplicatedStorage.TestFolder:GetChildren()) do
		print(v.Name)
	end
end

return module

Output:

GetChildren is not a valid member of ModuleScript

1 answer

✓ Accepted answer

Very simply, you forgot to require the ModuleScript:

script.Parent.MouseButton1Click:connect(function()
    local module = require(game.ReplicatedStorage.Modules.TestingModule)
    module:GetChildren()
end)

1 comment

0

Thanks.

This discussion is preserved as it was. New answers, comments, and votes are closed.