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

Is it possible to refer to a part inside of a modulescript that is called by a script?

Asked by 2 years ago
Edited 2 years ago

The title may be confusing but let me summarize what I'm trying to say.

I'm working on an advanced door system and I'm attempting to change one key thing. Each script that controls the doors is currently stuck within the door itself. I'm moving the door controller to be a modulescript inside of ServerScriptService. The way this works is that whenever the door needs to request a function (Such as changing the colour for it's keypad through the modulescript), the modulescript is told what part it should colour change and where.

If that is still confusing, let me dumb it down.

  1. Door script (In the door in my workspace) requests for the colour change script inside of my module script.

  2. Module script returns the colour change function, but realizes that it cannot access the screen. (Button1 is not a valid member of ServerScriptService "ServerScriptService")

  3. Script cannot continue because the modulescript trying to identify what it is being applied to cannot recognise where the screen it's trying to change is.

And yes, if you say that I need to tell the module script exactly where each button is through workspace, that would not be efficient for what I'm trying to do, as the door system is made to where you can add as many doors as you want without having to constantly rename and recode the script to get it to work. It should be as linear as possible.

Answer this question