What are Module Scripts? Roblox Scripting Explained

Поділитися
Вставка
  • Опубліковано 20 вер 2024
  • Confused about module scripts? Look no further! This 8 minute primer explains what you need to know along with a few examples to get you up to speed.
    DISCORD ► / discord
    TWITTER ►@gnomecodeRBLX

КОМЕНТАРІ • 250

  • @jsnotlout3312
    @jsnotlout3312 2 роки тому +210

    As a dev who has tried to explain module scripts to people, You did an amazing job explaining it clearly and very understandably!

    • @GnomeCode
      @GnomeCode  2 роки тому +30

      That's great to hear, cheers

    • @user-N04H
      @user-N04H Рік тому +6

      To you but not the average person trying to learn. I learned absolutely nothing from this. :/

    • @Sinz012
      @Sinz012 Рік тому +5

      @@user-N04H stop hating start learning 😂

    • @user-N04H
      @user-N04H Рік тому +7

      @@Sinz012 not hating its just to the average person who's starting I have to know what these terms mean and they weren't the best for me. That's what im saying.

    • @RakisahNew
      @RakisahNew Рік тому +5

      @@user-N04H this is advanced tutorial for people who have learned the basics, GnomeCode has a beginner scripting tutorial if you don't know the basics
      assuming the average person doesn't know the basics of scripting
      Hope this helps!

  • @tschesch6025
    @tschesch6025 2 роки тому +22

    I‘ve been scripting for almost 2 years now and never bothered to learn about module scripts x) very helpful video, thanks lot

    • @juanfleury
      @juanfleury 2 роки тому +3

      I've been scripting for almost 2 year and I still don't understand what is it.

    • @saviornogame
      @saviornogame 2 роки тому +4

      @@juanfleury its basically just reusable code that any script can call so you only have to edit the original module once (its very useful for keeping information or having reusable functions)

    • @juanfleury
      @juanfleury 2 роки тому +5

      @@saviornogame I understand now, but thank you anyways :D

    • @cub0id
      @cub0id 2 роки тому

      same

    • @Yan-ol4qu
      @Yan-ol4qu 2 роки тому

      SAME

  • @kaitotties
    @kaitotties 9 місяців тому +11

    great sense of humour, well-paced and thoughtful, immensely helpful. thanks for your hard work, gnomecode!

  • @kthuludev
    @kthuludev 2 роки тому +14

    almost a year of working on roblox game projects without getting into module scripts. this makes a lot of things clear, thank you gc your tutorials are very helpful and have been awesome!

    • @VodkaDoge
      @VodkaDoge 11 місяців тому

      same here, man, only difference is i dont make as many anime content as you

  • @Thelittlesthoboson
    @Thelittlesthoboson 6 місяців тому +2

    It seems as though you've taken a break from UA-cam or something, I'm not sure. I just found you today, but you are one of the best if not the best Roblox script tutorial makers for sure. You explain everything better than any teacher, and almost put things in storylines that make it fun and exciting in a way. Like your exploiting video where Billy goes on a rampage and you teach us how to tame him.
    I really would love to see you make a video about how to use Studio Explorer, IE, when to use Serverstorage, Serverscript Service, where to put things, where to never put things. As someone who is learning Roblox studio the biggest hurdle for me has been knowing when to use certain parts of the explorer, I found a video explaining it to some extent by another youtuber but he said some things like "Never use server storage, its useless" and a few other things that weren't entirely accurate.
    Basically, exploiters can ruin a lot of people's experiences, or flat out break games. I know they're supposedly rare and I should just focus on getting my game up and going but.. bleh. I just figure it would be easier to build it from the ground up knowing how to defeat the exploiters, rather than learning from losing players and getting dislikes because of them..
    That's why I think you're such a huge value to the community, Nobody wants to play with exploiters, nobody wants exploiters to ruin the experience for their players, players have less fun, devs lose players, it's only a win for exploiters..

    • @W5529XboxGameplay
      @W5529XboxGameplay Місяць тому

      Yeah he is really good at explaining.Here is a brief explanation.
      1. Server Script Service is where you will want to put all your normal scripts.
      2.Server storage is where you store stuff like objects that are not in the workspace so the player won't see them good for rotating maps. Sometimes values are stored their such as your stage in an obby it's basically where you store server stuff.

  • @Alaprine
    @Alaprine Рік тому +8

    Excellent introduction; concise and straightforward without sacrificing detail. Thanks!

  • @PineBloxx
    @PineBloxx 2 роки тому +14

    I’ve been needing this for a long time. Thanks so much gnome!

  • @cinemalazare4850
    @cinemalazare4850 2 роки тому +4

    as a begineer this is am thinking this is very useful for things like jumppads or killblocks maybe sword's or honestly anything. thanks i learned alot :)

  • @therealsuper5828
    @therealsuper5828 2 роки тому +51

    great tutorial!
    one thing i noticed with the SpawnFruit() function, is that you put the function in the same table as the fruits.
    SpawnFruit("SpawnFruit") will error, because further in the function it mentions fruit[name].Color (Color is not a member of a function)

    • @triggvfx5784
      @triggvfx5784 2 роки тому +4

      Dam That's crazy!

    • @pthwo
      @pthwo Рік тому

      thats because you didnt set a color in

    • @terrybrawlstarsaddict
      @terrybrawlstarsaddict Рік тому

      it worked for me

    • @reminderIknows
      @reminderIknows Рік тому +1

      This comment is incorrect since you use [] when referencing something in a table
      fruit[name] references to the fruit being sent in a parameter
      for example
      fruit.SpawnFruit("Kiwi")
      instead of fruit[name], it will instead return Kiwi
      so Kiwi.Color = Color3.new(0.223529, 0.392157, 0.027451)

    • @therealsuper5828
      @therealsuper5828 Рік тому

      @@reminderIknows try it out, i know im correct about this

  • @wallop560
    @wallop560 2 роки тому +10

    These could defo be useful to beginners. Great job man!

  • @ricardo3201
    @ricardo3201 2 роки тому +3

    Very Usefull for bigger projects! Thanks for making this video

    • @GnomeCode
      @GnomeCode  2 роки тому +1

      Thanks for the good vibes!

  • @slingdev
    @slingdev Рік тому +1

    Trying to just new learn skills that I might need in development, this one sure will help. Perfect teaching, thanks

  • @usko_
    @usko_ 2 роки тому +3

    This is so handy, thank you so much. The video was short, and you explained it so well.

    • @ItsPedro9898
      @ItsPedro9898 6 місяців тому

      I though it was boomsasok for 30 secs

    • @Abit_
      @Abit_ 5 місяців тому

      @@ItsPedro9898 j t o h

  • @poluefemus
    @poluefemus 10 місяців тому +1

    thanks man, best explanation i’ve seen

  • @SIMPLE_FORM
    @SIMPLE_FORM 8 місяців тому

    As I watched your videos,I see that your explanation is perfect,the things that I didn't understand with other,I got it by your explanations

  • @epixerty
    @epixerty 2 роки тому +4

    I started scripting a bunch of months ago and I've been wondering what module scripts were, I haven't paid much attention to them, thanks for this video, now I will be able to use module scripts

  • @profiley.
    @profiley. 3 місяці тому

    Short Explanation:
    Module script needs a Script object that has require(Insert Module Script Location) in it

  • @silvermist_studios
    @silvermist_studios Рік тому

    Thank you so much, this tutorial is really easy to understand and you explained it so well! Keep going!

  • @sir.potgreyscale3897
    @sir.potgreyscale3897 2 роки тому

    Thank you so much for teaching me! I've been always trying to find out how to use Module Scripts, but I was still confused. But after watching this video, I learned how to use module scripts well! (I SUBBED BTW)

  • @TheDunClub
    @TheDunClub 9 місяців тому

    who dosent love this dude explaining stuff clearly

  • @CT_Gree
    @CT_Gree 2 роки тому

    for the example shown at 3:20 or so, you can just do:
    return {
    ["Apple"] = {
    Price = 50,
    }
    }

  • @akiprox7
    @akiprox7 Рік тому

    Thank you so much man! This will really help me organize scripts!

  • @bigjimmyrblx5601
    @bigjimmyrblx5601 2 роки тому +2

    This is one of the few tutorials i have actually learnt from, thank you so much!

  • @robertsnoname8847
    @robertsnoname8847 Рік тому +1

    So... it's kinda like the reason why you want a separate file for all of your CSS in html

  • @davidh6217
    @davidh6217 Рік тому

    Best tutorial on Roblox Studio I have ever seen, thanks!

  • @dunghuynh3884
    @dunghuynh3884 2 роки тому +1

    People all need explain like this. Thanks for this video
    I subcribed

    • @GnomeCode
      @GnomeCode  2 роки тому +1

      Glad it helped, thanks for the sub!

  • @amarondas-cm6rh
    @amarondas-cm6rh 6 місяців тому

    YO BRO TYSM! I FINNALY UNDERSTOOD WHAT MODULE SCRIPT NEED! TY

  • @TipoHombre
    @TipoHombre Рік тому

    This is such an amazing tutorial, it's actually very good

  • @feodorborisevich
    @feodorborisevich 2 роки тому

    Perfect introduction to module scripts. Many thanks

  • @jett27j30
    @jett27j30 5 місяців тому

    I watched this a year ago, never thought I'd use module scripts, and here I am, watching it again because I need a module script for functionality.

  • @capturedchild
    @capturedchild 2 роки тому +1

    my brain focused so much in this and i learned a LOT

  • @deadbrav
    @deadbrav Рік тому +1

    Fun fact: module scripts are very useful when making programming languages

  • @itsnotAZ
    @itsnotAZ 2 роки тому +1

    Thanks!I abondoned a HUGE amount of projects since the code was messy...! If I only knew...

    • @QUBIQUBED
      @QUBIQUBED Рік тому

      Try making smaller projects or work on a friend’s project for a while to learn organizing code better

    • @itsnotAZ
      @itsnotAZ Рік тому

      @@QUBIQUBED Unfortunately, I'm not into roblox game dev anymore. I have moved on to other larger game engines, which i think your advice still applies. I will take it into consideration next time I work on a project.

  • @davidguo9923
    @davidguo9923 2 роки тому +1

    Your the best garden gnome

  • @SupNote
    @SupNote Місяць тому

    w apple teaching, keep it up

  • @dingus625
    @dingus625 Рік тому

    u explained this in the best way possible

  • @HowToName559
    @HowToName559 2 роки тому +2

    Hey! GnomeCode why i can edit teddy game?

  • @Marioman73
    @Marioman73 2 роки тому +1

    Module Scripts: Commonly used in virus-related scripting because of their ability to be required from the Library.

    • @krianee6662
      @krianee6662 2 роки тому

      pensi

    • @xondisw
      @xondisw 2 роки тому

      @@krianee6662 that word translates to think

  • @lightpin638
    @lightpin638 2 роки тому

    Yay a post!!

  • @rex5282
    @rex5282 2 роки тому

    Fun stuff, knew what modules do but never knew you can use functions

  • @n_kachi
    @n_kachi 2 роки тому

    Even though i dont really use these, im happy that know i understand them better, thank you

  • @ragingatrix9697
    @ragingatrix9697 Рік тому

    This is a great tutorial. It really helped me a lot. Thanks 👍

  • @mob1len00b3
    @mob1len00b3 Рік тому

    bro this is so useful !

  • @aleserver2454
    @aleserver2454 Рік тому

    Workspace.Script:3: attempt to index nil with 'Oranges'

    • @QUBIQUBED
      @QUBIQUBED Рік тому

      Wrong quote, you have to use double quotes for string….

  • @asrielofhyperdseath
    @asrielofhyperdseath Рік тому

    Hey thanks! I'm not really a good scripter but I wanted to know what this does so I'll know in the future!

  • @Scober420
    @Scober420 Рік тому

    Gnome code doesn’t need the toolbox, the toolbox needs him.

  • @BaldyDevRBLX
    @BaldyDevRBLX Рік тому

    wow this is great, helped me alot managed to impethis into my game

  • @ShadowClaw_Dev
    @ShadowClaw_Dev 2 роки тому

    Thanks now I understand module scripts very well :)

  • @idkmanreal0008
    @idkmanreal0008 11 місяців тому

    i use modulescripts to make portable GUIs like a portable serverside executor or a gui to nuke people where i just do something like this to make it(simplified version of my nuke gui):
    (varibles blah blah blah like repl storage)
    local module = {}
    function module:GUI(plr)
    local gui = script.ScreenGui:Clone
    gui.Parent = players:FindFirstChild(plr).PlayerGui (players here is Players service that is defined in variables)
    end
    return module

  • @OversizedPringleToe
    @OversizedPringleToe 2 роки тому +1

    G’Nome!

  • @Jappley
    @Jappley Рік тому +2

    i love how he says "lilcal script" for local script lol

  • @jessipeppermintz6372
    @jessipeppermintz6372 2 місяці тому +1

    i am currently spending an hour and a half messing with random things, trying to get it to not say "requested module experienced an error while loading" every time i press play. EDIT: ok i finally fixed it, but i have a question, how would i go about putting the object i spawned from the module script list into a player's backpack?

  • @VodkaDoge
    @VodkaDoge 11 місяців тому

    i have a feeling this will expand my journey into game making, also, tiny question for experienced devs.
    Let's say I want a lot of blocks to share the same script! Print "Touched" when a player touches them.
    Will it work to just put them all in the same folder, make a moduleScript inside that folder that has the actual printing script, and have server scripts that require the moduleScripts?
    Example:
    ModuleScript: [Code to detect touch and print message]
    Script: require(BlockFolder.ModuleScript)
    edit: Yeah, you can. Did it by myself after like 15 minutes.

    • @coolbudYT
      @coolbudYT 10 місяців тому

      I mean I don't think doing modules would be great for it but you can use loops👍

    • @VodkaDoge
      @VodkaDoge 10 місяців тому

      @@coolbudYT nah, worked perfectly. better than anything else, if you want i can share the code

    • @НазарШульга-э5с
      @НазарШульга-э5с 9 місяців тому

      u can just put all parts into one folder, then use for _,v in pairs(folder:GetChildren())
      and v.Touched:Connect(function()

    • @VodkaDoge
      @VodkaDoge 9 місяців тому

      @@НазарШульга-э5с that's overcomplicated ngl, there's a much simpler and compact way, as i said, i'll gladly share the code

  • @livecorp3232
    @livecorp3232 Рік тому

    ohh hell no, I know he did not just say "and everybodysss favorite FRUIT, A tomato!!!", My mind just committed suicide.

  • @akiprox7
    @akiprox7 Рік тому

    amazing man!

  • @yelezi7950
    @yelezi7950 2 роки тому +1

    Your next video should be about anti-exploit scripts.

  • @JustCritz
    @JustCritz Рік тому +1

    I don't remember bricks being a fruit.

  • @MCAsh-il9cq
    @MCAsh-il9cq 2 роки тому

    Are you going to do videos on how you changed the teddy ai or building chapter 4???

  • @Skroopz
    @Skroopz 5 місяців тому

    thanks i never knew what module scripts are now inknoe

  • @Chmze799
    @Chmze799 2 роки тому

    Me, making an RPG with a core folder half comprised of module scripts plus 2 module scripts for each and every kind of monster except bosses:
    "ORGANIZATION 100"

  • @dvm1126
    @dvm1126 2 роки тому +1

    nice outro!

  • @HayFatYT
    @HayFatYT 5 місяців тому

    Americans: Toe-May-Toes
    Anywhere else: Toe_Mah_Toes

  • @gabegamez1018
    @gabegamez1018 Рік тому

    Wow I code on roblox, this will help me make my scripts not so long! Thx so much! 😍

  • @AnshumanPareek1
    @AnshumanPareek1 2 роки тому +1

    Hi, I am making a game like CS:GO surf in Roblox and, I want to make part that when touched increased the player speed every second and when player dies it resets automatically and speed is also show with the help of GUI on player screen. (The speed should only increase for the player who touches it.) Please help me. I am stucked.😥😥😥

  • @TheNewDev09
    @TheNewDev09 Рік тому

    This video helped me a lot!

  • @UltraDubzYT
    @UltraDubzYT Рік тому

    the fruit dictionary made me forget basic scripting

  • @user-bp2rt9ou8z
    @user-bp2rt9ou8z Рік тому

    as a developer and a exploiter this information is useful for backdoors

  • @edufabricio
    @edufabricio Рік тому

    Is the Module similar to a Class in OOP ? i got it. Nice and very clearly explanation 🙌

  • @hike8932
    @hike8932 Рік тому

    so basically modulescripts are functions except in physical forms ?

  • @JannaK78
    @JannaK78 Рік тому

    Im extremely annoyed by Module scripts. Everytime I add a Module Script into a Script or also try to seperate them, everything I type into the Module Script the Script will just copy it. Same way around. And if I delete everything in the Module Script, the Script will also delete everything.

  • @seeray11
    @seeray11 8 місяців тому +1

    Could you replace the “name” in the function in the module script with whatever. I didn’t get that part. How does name mean name, since I couldn’t find anywhere in the script that makes the name mean name. I thought it just meant fruit.SpawnFruit, which doesn’t
    mean anything until you assign a function to it.

  • @Justherefora
    @Justherefora 8 місяців тому

    Thank you man! H, Verry cool.

  • @Fayroll5
    @Fayroll5 11 місяців тому

    as a person who likes giant scripts, i can confirm i will rarely-never use these.

  • @davidguo9923
    @davidguo9923 2 роки тому +1

    1:24 my favorite fruit is a tomato

  • @grandeurgaming2165
    @grandeurgaming2165 2 роки тому

    Yes please do on OOP. I would love to watch it.

  • @WearWQLF
    @WearWQLF 2 роки тому +1

    and could you do a video of effect like beam explosion effect smoke it could be useful for me or the comunity thanks

  • @JeLeff.
    @JeLeff. 10 місяців тому

    3:08 I just blinked 💀

  • @BJodfuo
    @BJodfuo 2 роки тому +1

    1:32 tomato is not fruit

  • @ardatimeofc
    @ardatimeofc 11 місяців тому +1

    Can I use module scripts to make like a chance percentage on egg hatching system?

  • @PauloCosta-it2pv
    @PauloCosta-it2pv 2 роки тому

    Amazing tutorial thank u!

  • @narutouzumakinarutouzumaki4224
    @narutouzumakinarutouzumaki4224 2 роки тому

    Amazing Tutorial!!!

  • @jbplays99
    @jbplays99 2 роки тому

    I never knew how to use a modulescript until now...

  • @MudHoleCreation
    @MudHoleCreation 22 дні тому

    So... they are classes/structs like in the rest of programming languages.

  • @markhorst-uy1sm
    @markhorst-uy1sm Рік тому

    So helpful!

  • @animationz4667
    @animationz4667 7 місяців тому

    Why can’t I just write everything directly into one main script instead of using a normal and a module script?

    • @benja2998
      @benja2998 6 місяців тому

      i think its to organize since organizing is useful for it to be easy to add new code in the script without destroying the entire game like moving a single domino in a stack of dominoes

  • @bloxer_7696
    @bloxer_7696 2 роки тому

    Roblox needs to give guy a starcode

  • @sealsnatch
    @sealsnatch 10 місяців тому

    Most of my coding knowledge is in c#, are these like classes?

  • @nottony5200
    @nottony5200 2 роки тому

    Wish when I was learning scripting this video existed

  • @xlubir1569
    @xlubir1569 9 місяців тому

    Good Video😃

  • @markojotovic8991
    @markojotovic8991 6 місяців тому

    wow its could be super usefull ,remind me of Json or Objects in JS

  • @Internet_Explorer3773
    @Internet_Explorer3773 Рік тому

    wait Tomato is a fruit? Isn't it a vegetable?

  • @sussbob
    @sussbob 2 роки тому

    Can you make a tutorial on how to make a morph menu screen (like a gui or a menu) with a list of options to morph into (creatures or animals not robloxian parts) and when you click it. You morph into it? Then make the menu for morphing disappear unless you respawn.
    I wanna make a monster battler game
    This Is something that had been very high requested for a very long time but nobody made a tutorial for it

  • @HurelyDev
    @HurelyDev 2 роки тому +1

    I have idea for Teddy, a season pass!

  • @FSHY.
    @FSHY. 2 роки тому

    Video streak??

  • @CheezyGaming0910
    @CheezyGaming0910 2 роки тому

    That was so USEFUL!!! Thank you for helping me so much!!!

  • @gentleman12702
    @gentleman12702 11 місяців тому

    how did he know i like tomatoes so much

  • @carttof4962
    @carttof4962 Рік тому

    very nice video

  • @ChristopherThePiss
    @ChristopherThePiss 2 роки тому

    Already know but it was still cool to get a recap

  • @seeray11
    @seeray11 8 місяців тому +1

    God vid tho

  • @planeman4453
    @planeman4453 2 роки тому

    Nice video, any chance you could do a video in utilising them in a game? I'm trying to make a survival game, and I'm using module scripts, but I have problem. I have an inventory module which needs to have a 2 way communication with my hotbar module, but I can't have that. Would I need to merge the modules into one big one?

    • @zwwz1424
      @zwwz1424 2 роки тому +1

      never merge modules together, it's not necessary in 99.9% of the cases
      modules are there to organize code and support reuseability

    • @planeman4453
      @planeman4453 2 роки тому

      @@zwwz1424 yeah, but I can't make it work otherwise. I need both modules to require each other, which causes an error.

    • @zwwz1424
      @zwwz1424 2 роки тому

      @@planeman4453 put the functions you need from both modules in a different one if possible

    • @planeman4453
      @planeman4453 2 роки тому

      @@zwwz1424 i can't. That defeats the whole point of having them as 2 modules. Should i just merge the hotbar with the inventory then (modules)?

    • @zwwz1424
      @zwwz1424 2 роки тому

      @@planeman4453 i guess yeah