how to write CLEANER code - Roblox Studio

Поділитися
Вставка
  • Опубліковано 21 тра 2024
  • ScriptBox is good for beginners! Not because the scripts are good, but because they serve as a learning opportunity for beginners on how to improve code! 😉
    Check out the game here:
    www.roblox.com/games/73822153...
    Ever wanted to learn Roblox Studio & scripting? Check out my course:
    bit.ly/LuaScriptingCourse
    Use code DEV2024 for 33% off!
    My linktree:
    linktr.ee/crusherfire
    Music used:
    Please, Don’t Forget Me by | e s c p | www.escp.space
    Eternal Springtime by | e s c p | www.escp.space
    Happy scripting!
  • Ігри

КОМЕНТАРІ • 94

  • @ThatGuyNamedBender
    @ThatGuyNamedBender 26 днів тому +38

    I've never seen more brutal critiquing of work than I've seen in the programming field 😂 I've been programming for almost 2 decades now and I've seen more critical critiquing of code than I've seen chefs and artists getting critiqued lmfao love it

    • @restindeath1755
      @restindeath1755 25 днів тому

      yeah man.. its wild.

    • @MapleRift
      @MapleRift 24 дні тому +1

      He wasn’t brutal though? He corrected the mistakes and offered better alternatives

  • @simvoid4347
    @simvoid4347 25 днів тому +22

    I actually do like using 1 line if statements with return statement, but I use them as guard clauses. It is personal preference though.

    • @mr_griffolukegriffiths9166
      @mr_griffolukegriffiths9166 23 дні тому

      Me too 😊 so long as they are clearly guard statements and only returning nil or false

    • @Sadjhj
      @Sadjhj 20 днів тому +1

      Yeah same

  • @-zeeb-585
    @-zeeb-585 24 дні тому +3

    PLEASE DO MORE OF THIS AS A LEARNING CODER THIS HELPED TONS

  • @Hyllested_
    @Hyllested_ 18 днів тому

    Great video!
    I was a bit worried when I saw the title, as I saw this game myself, and didn't get the best impression, but I was glad to see this was some good criticism of the game!

  • @nicknameita-yc2ct
    @nicknameita-yc2ct 26 днів тому +13

    I remember playing this Game a few weeks ago, i knew something was off about it.

    • @hellohennessy3462
      @hellohennessy3462 26 днів тому

      what is off about it?

    • @nicknameita-yc2ct
      @nicknameita-yc2ct 26 днів тому +2

      @@hellohennessy3462 i don't really like the way they make scripts

    • @hellohennessy3462
      @hellohennessy3462 25 днів тому +1

      @@nicknameita-yc2ct Yeah, their scripts have a few flaws, but it is easy to understand for a newbie. Better programmers like you and I don't need these kinds of things.

    • @simvoid4347
      @simvoid4347 25 днів тому

      @@hellohennessy3462 The code sucks and simple scripts are locked behind a paywall (even though all the code behind this paywall is super simple and common stuff that you can find for free all over the internet). The learning school that the game links to is trash too, I did all 4 of the Luau tests and the "advanced" test was full of what I would consider beginner material. It's just another cash grab game, similar to these overpriced courses I see many "developers" promoting.

    • @4amanda4
      @4amanda4 17 днів тому

      @@hellohennessy3462 issue is these scripts do nothing for a learning developer esp since vital things like datastores or similar are kept behind a paywall
      this game in general is a scummy cash grab from aspiring devs who are already fucked over by the platform enough

  • @mr_griffolukegriffiths9166
    @mr_griffolukegriffiths9166 23 дні тому +1

    Would connect the .Died with :Once() to avoid some weird edge cases where died manages to fire multiple times 😊

  • @Blue-tq3uj
    @Blue-tq3uj 25 днів тому +2

    this is great, can you make it into a series?

  • @llliiimmmeee
    @llliiimmmeee 25 днів тому +3

    My genuine advice for new developers:
    Make stuff completely yourself, abuse the fuck out of the docs, and feel free to rewrite someone else's code if you INTEGRATE and IMPROVE
    Also, don't immediately start working on someone's dev team, embarrassing how many people figure out lua then immediately "yep time to work in a sweatshop"

  • @begi-dll
    @begi-dll 25 днів тому +3

    Would you mind making roblox studio settings / plugins video? I would love to watch it and configure my studio as u have

  • @Z3SC
    @Z3SC 25 днів тому +1

    Can use :Once with the humanoid Died function but should function exactly the same since connections get cleaned when player dies.

  • @itso6778
    @itso6778 25 днів тому +2

    8:20 i dont think this saves more memory cause we still use anonymous function BUT it is 10x more readable especially if you have a lot of instructions to execute in those functions
    Very good video broskillet

  • @okage_
    @okage_ 26 днів тому +3

    good video, i did not consider the increased memory from anonymous functions

  • @rud4sek793
    @rud4sek793 25 днів тому +1

    Can you make a video where you show some keyboard shortcuts when writing code?

  • @epixerty
    @epixerty 26 днів тому +1

    13:32 be careful with that, if the sound id doesn't load for whatever reason it will infinitely yield the code
    sounds have a property called IsLoaded to know whether the sound loaded or not, you can check if its true, and if it isnt just pick another sound

    • @RedsquareR
      @RedsquareR 25 днів тому +1

      never thought about this when making my music system, thanks for the tip.

    • @epixerty
      @epixerty 25 днів тому +2

      @@RedsquareR yeah i made a music system once and had this issue myself

  • @yal1621
    @yal1621 25 днів тому +5

    for the instant load script, you generally wouldnt need an entirely new ondeath function just to call another function. you also dont need to use :Connect, as the player only dies once per character
    correct way:
    local function onCharacterAdded(character)
    character.Humanoid.Died:Wait()
    Players:GetPlayerFromCharacter(character):LoadCharacter()
    end

    • @ExpoM3rker
      @ExpoM3rker 25 днів тому +2

      Can’t you also change the RespawnTime property in the Players service..??

    • @silly8742
      @silly8742 24 дні тому

      @@ExpoM3rker That's what I was thinking, just scrap the code entirely and change the respawn time.

    • @wedoalittletrolling723
      @wedoalittletrolling723 23 дні тому

      @@silly8742 engine-side > any scripted alternative
      it just you dont get access to the engine side on roblox

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

      What happens when a player leaves the game while the script is still waiting for the humanoid to die? I would assume it stops yielding, but when I tried it in studio the code after it doesn't run, but I also have no way of checking whether the script actually stopped yielding (as far as I know)

    • @fourone1254
      @fourone1254 20 днів тому

      @@berendberend702did you know that all function relating to an object are terminated the second the object is nil or gone? same with doing :Destroy() on a part that’s linked to a function, that function will no longer run to that part because it was terminated

  • @artem-kt2gh
    @artem-kt2gh 25 днів тому

    i actually saw game from the save dev where its like a bunch of tests, i went in clicked on the hardest difficulty (advanced) and the questions were... what is debris, what is pcall()...

  • @MS-lb9yd
    @MS-lb9yd 25 днів тому

    What’s your studio color settings theme?

  • @zxkver8943
    @zxkver8943 26 днів тому +2

    mmm chocolate pudding

  • @HDWare
    @HDWare 20 днів тому

    What’s your edition settings?

  • @PolarZ0
    @PolarZ0 19 днів тому

    3:00 How do i get the little menu at the bottom right and the size of the part to show up

  • @cedricsonaquevido1565
    @cedricsonaquevido1565 26 днів тому

    how does your script editor look like that? (more of the look of the text (arrows and dots) and not its colors) id appreciate if you could tell me, thx

    • @artem-kt2gh
      @artem-kt2gh 25 днів тому

      studio settings and you can change all colors in there

  • @localsalty
    @localsalty 25 днів тому

    good video

  • @MashySob
    @MashySob 25 днів тому

    how do you change multiple things at once like when changing the variable name

    • @artem-kt2gh
      @artem-kt2gh 24 дні тому

      ctrl shift r, or just right click the thing and you will see all the tools

  • @Billy-gm4wl
    @Billy-gm4wl 23 дні тому

    whats the purpose of doing player : Player when you pass parameters, ive seen it a few times but i have no idea what it does

    • @wedoalittletrolling723
      @wedoalittletrolling723 23 дні тому

      it's just syntax sugar, if you know all the properties and methods of an instance, you don't need it.

  • @Spooky.Studios
    @Spooky.Studios 25 днів тому

    6:50 or just change the RespawnTime from 5 to 0
    lol

  • @byteblox100
    @byteblox100 15 днів тому

    i will name them with 1 letter

  • @rud4sek793
    @rud4sek793 24 дні тому

    what is :: doing in luau?

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

    Hey. I wanted to ask about while true do task.wait(1) end and while task.wait(1) do end. Is there any difference between these two, if so, which one is better?

    • @fardmonkegaming
      @fardmonkegaming 18 днів тому

      not a pro scripter, but while task.wait() do would make more sense imo, it's short and it does the exact same thing as while true do task.wait(). unless it's like you plug it into a variable like local lol = true and then while lol do task.wait(). idk could be wrong

    • @Martanus
      @Martanus 18 днів тому

      @@fardmonkegaming im not really sure cuz some ppl said it uses more memory or smth

    • @fardmonkegaming
      @fardmonkegaming 16 днів тому

      ​@@Martanus which one, while wait() do or while true do wait()

  • @Tamla1959
    @Tamla1959 25 днів тому

    i dont think wait is deprecated (yet), it just waits with throttling, where as task.wait() does not, but task.wait() is better because of that.

    • @Fimutsu
      @Fimutsu 25 днів тому

      it is deprecated

    • @Tamla1959
      @Tamla1959 25 днів тому

      @@Fimutsu it's not

    • @crusherfire1
      @crusherfire1  25 днів тому

      @@Tamla1959 If you search for the legacy wait function on the documentation page, it's marked as deprecated. I assume they haven't added the markings in studio since so many scripts still use those legacy functions (including CoreScripts)

    • @Tamla1959
      @Tamla1959 24 дні тому

      @@crusherfire1 ah right

  • @artem-kt2gh
    @artem-kt2gh 25 днів тому

    6:25 am i the only one who thought to just change property RespawnTime in Players service to 0?

  • @CrazyDoodEpicLeaves
    @CrazyDoodEpicLeaves 26 днів тому

    3:56 How did you do that, changing all instances of one variable at the same time?

    • @epixerty
      @epixerty 26 днів тому +1

      select anything and press Ctrl+D

    • @CrazyDoodEpicLeaves
      @CrazyDoodEpicLeaves 26 днів тому

      @@epixerty That sadly did not work

    • @2muchtntstudios925
      @2muchtntstudios925 26 днів тому

      Hold alt and click where u want ur other cursor to be

    • @artem-kt2gh
      @artem-kt2gh 25 днів тому

      ctrl shift r

    • @epixerty
      @epixerty 25 днів тому

      @@CrazyDoodEpicLeaves it works for me

  • @jonathan10007
    @jonathan10007 25 днів тому

    oh man if you saw my code anything goes

  • @AszectiRoblox
    @AszectiRoblox 25 днів тому

    W vid

  • @hike8932
    @hike8932 25 днів тому

    im a scripter who can script almost anything however my scripts arent the best optimized when it comes to prevent memory leaks and reducing overall performance issues. i was recently told by a scripter to optimize and make my code better to which i had no idea how to. but this video was in my recommended section and thank god i now know what i can do about it. this was a very informative video. thank you @Crusherfire
    Edit : Also can you tell me what color scheme you were using, it looked pretty good, im just using the default roblox one

    • @MapleRift
      @MapleRift 24 дні тому

      It’s in his channel’s community tab

  • @real_quandie
    @real_quandie 25 днів тому +1

    this game is useless money farm, like fr, it asking for robux to get scripts that you can find in internet

  • @Lkrupa
    @Lkrupa 25 днів тому

    Your never going to make me use task.wait!!!!!!

  • @CRT_YT
    @CRT_YT 21 день тому

    this game is really gross they make you pay money for "intermediate" and "advanced" scripts like you couldnt just open google which would honestly give you way more useful information. this is legit a trap for new scripters.
    whoever made this game deserves to get banned off the platform istg

  • @VectoorX
    @VectoorX 25 днів тому

    Their code has to be the most laziest code I've ever seen 😭😭

  • @CreatorProductionsOriginal
    @CreatorProductionsOriginal 25 днів тому +2

    Just realized *most* of these are about making code cleaner to look/read, which doesn’t really apply to me then since I only create games by myself, but I’ll keep the tips in mind in case I get paid for something, or if it’s intended for players to look at my code, it’s like making your bed, you don’t need to do it and could be seen as a waste of time if you live by yourself and doesn’t bring anyone home often, but something you should do if you share that same bed or the bedroom
    Edit: how often y’all forget your own scripts? It’s not that hard
    Edit2: Apparently y’all do forget your own code very easily, either way, it’s still useless to me, even if it’s useful to you

    • @kai-o-kai
      @kai-o-kai 25 днів тому +4

      Writing clean code ABSOLUTELY applies to solo developers. For one, you don't know 100% that your game will always be a solo project. Second, even if it is, you in 6 months is not you. You in 6 months will not remember the nuances of your code and they will appreciate clean code to read and understand again.

    • @artem-kt2gh
      @artem-kt2gh 24 дні тому

      @@kai-o-kai completely agree, if you take a big break and comeback to the code, its like being a new person who sees it for the first time, and code being cleaner does benefit, the only case where it wont benefit is when you're a solo dev and you do it on one go or its just a really really small project

    • @MapleRift
      @MapleRift 24 дні тому

      Yeah this is wrong, clean code absolutely benefits a solo developer. If you don’t look at a script’s source for a week or two then come back to your disaster of a script, you’re gonna be super confused.

    • @CreatorProductionsOriginal
      @CreatorProductionsOriginal 24 дні тому

      @@kai-o-kai key word: most

    • @kai-o-kai
      @kai-o-kai 24 дні тому

      @@CreatorProductionsOriginal "how often yall forget your own scripts? its not that hard"
      Have you... ever spent more than a month on a complex game?
      Also, *most* is still making an assumption that they don't apply. Which they do.

  • @Teknifiant
    @Teknifiant 21 день тому

    ScriptBox is more like a ShitBox imo

  • @tower9602
    @tower9602 25 днів тому

    Oop sucks, return back to functional programming

  • @hinokamitanjiro-ow8cr
    @hinokamitanjiro-ow8cr 24 дні тому

    the most pickiest scripter ive ever seen LOL + the thing at 7:20 doesnt save memory its the same thing
    all you're doing throughout the video is rewriting what already works to make it look like its better but really you're doing unnecessary things

    • @crusherfire1
      @crusherfire1  24 дні тому

      I'm very picky! 🤯

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

      but its cleaner.... as noted by the title. If you've ever worked with other people in a dev workspace, you'll understand how important stuff like this is