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

[SOLVED LOOK IN ANSWERS broken module] (Modules)?

Asked by 4 years ago
Edited 4 years ago

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?

2 answers

Log in to vote
1
Answered by
Xapelize 2658 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

Ok, let me explain to you:

--= What is a Module Script? =--

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.

Data by developer.roblox.com, changed.

--= How does Module Script used for? =--

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.

Data by developer.roblox.com, changed.

--= Code samples =--

--= Simple Module Script example =--

-- 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:)

0
ur post didn't help me at all but i see u put some effort so i'll give u rep because i try to answer things too for rep HappyTimIsHim 652 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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

0
I typed 10 minutes long and you say it was a bug, my answer is ripped. Oof Xapelize 2658 — 4y
0
Usually I try to keep it more professional, but everything in this question made me chuckle. SteelMettle1 394 — 4y

Answer this question