I really don't need code for this. I don't need sleep. I need answers. I put a module in StarterPlayerScripts and I literally can't find the module after i click play. I do it it says module is not a valid member of playerscripts i tried putting it in a starterpack and same result. I tried to do this with a localscript in starterpack, startercharacterscripts, and a local script in startercharacterscripts. I literally searched for it in game and the module is just not in the game after i click play. Why?
Ok, let me explain to you:
Module Script
is used to hold functions and variables to be used by other scripts. They can even be used to run functions for multiple games if required as an asset.
A Module Script
is a type of Lua source container that runs once and must return exactly one value. This value is then returned by a call to require
given the ModuleScript as the only argument. Module Script
run once and only once per Lua environment and return the exact same value for subsequent calls to require
.
It’s important to know that return values from Module Script
are independent with regards to Local Scripts
and Script
, and other environments like the Command Bar. Using require
on a Module Script
in a Local Script
will run the code on the client, even if a Script
did so already on the server. Similarly, in Roblox Studio, using require
on a Module Script
in the hierarchy with the Command Bar will give a similar behavior. So, be careful if you are using a Module Script
on the client and server at the same time, or debugging it within Studio.
-- Tables are store multiple values in one variable local my_functions = {} -- Add a few functions to the table function my_functions.foo() print("Foo!") end function functions.bar() print("Bar!") end -- ModuleScripts must return exactly one value return my_functions
Sorry that I used the Developers Roblox datas without changing anything, but my English is pretty bad, also not good at explanation. Sorry!
But if this worked to you, mark this as the correct answer, thanks!
Cheers:)
SOLVED JUST A STUPID BUG THE MODULE SCRIPT WAS BROKEN IT DIDN'T SAVE AND DIDN'T WORK I JUST MADE A NEW ONE WITH THE EXACT SAME CODE AND IT WORKS