I have a modulescript in replicated storage that is accessed by the client, but i want it to search through all the players in the game and change something in their playergui. The problem is, I keep getting the “PlayerGui is not a valid member of __” error. I think this is because the module script is client sided as of right now, because the client can only access their specific playergui and not others. How would I get the module script to run this code for the server?
Use a script on the server that calls require() on your module script.
So should I make a remote event? Because the client tells the module to refresh, so maybe I relay the message to the server instead?
I think there may be something fundamental you are misunderstanding.
Can you show us the ModuleScript?
I am 100% certain the module scripts’ code is fine, but i think the module may only be running locally because I am calling the functions from a local script. Thats why I am wondering if I need a server script to call functions related to the server instead.
Edit: I also would like to add that it is only my 1st week learning how to use module scripts, so I think this is the reason because it gets confusing as to whether a module script is local or global for me.
No worries
If you run code from a module on a LocalScript, it will run locally. The same concept occurs with legacy scripts. Userunmanned’s solution should work; just require the module from a server script so the code will run on the server, allowing you to access every player’s PlayerGui.
I just realized that I am calling functions from the client script, but then the module script calls the function that causes it to loop through all the players (so it calls and runs the function itself). Will that affect anything?
And I just tested it out, it still failed (My serverscript has only one line requiring the module)
You should* be calling the module’s function from a script… that’s the point of a module. The fact that the module is calling a different function from the module is fine. It won’t affect anything. However, the functions from the module must be called on the server in order to be ran on the server, not the client.
Okay I understand now, Thank you for the explanation! I will follow up with how everything goes