Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you use LocalScript and a ModuleScript together?

Asked by 5 years ago

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.

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 namespace25 594 — 5y
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. ScuffedAI 435 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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!")
Ad

Answer this question