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

How do you use LocalScript and a ModuleScript together?

I have no problem using a ModuleScript and a Script together, but I'm stuck on trying to use a ModuleScript and LocalScript together (hope that makes sense). I keep getting an error that says:

14:08:37.032 - TestingModule is not a valid member of ServerScriptService

LocalScript

module = require(game.ServerScriptService.TestingModule)

tool.Activated:Connect(function()

module:throw()

end)

ModuleScript:

function module:throw()

print("testing")

end

Hope you lads can help me out, thanks.

2 comments

0

I see your problem. Here: this will help with what you're trying to do with the colons. https://developer.roblox.com/articles/Method

0

ServerScriptService and ServerStorage are places the server only can access. If you want the client to be able to access the module, then you should move the Module to ReplicatedStorage.

1 answer

I'm not sure how you're using the module. If you are using methods or what. But I wrote an example if you don't know how to use module's or something.

Module Script:

local module = {
		event = function(argument)
    		print(argument)
		end;
}

return module

Local Scirpt:

local module = require(game:GetService("ReplicatedStorage").Module) --[[ Example of the parent]]

module.event("Hello, module script!")

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