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

How to access a ModuleScript from a normal game script?

Asked by 3 years ago
  1. have a modulescript in ServerScriptService
  2. have a normal script that is called when I touch a brick
  3. I want the normal script to be able to access methods from the module script

Is this possible? What is the visibility from normal scripts on bricks into ServerScriptService?

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

Use require() to use a ModuleScript in your Script. If you want to run a function from a module when a brick is touched, you could do something like this:

local myModule = require(game.ServerScriptService.MyModule)

script.Parent.Touched:Connect(function()
    myModule.myFunction()
end)

https://developer.roblox.com/en-us/articles/modulescripts

Ad

Answer this question