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

How to access a ModuleScript from a normal game script?

  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

✓ Accepted answer

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

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