how to write CLEANER code - Roblox Studio

  Рет қаралды 8,723

Crusherfire

Crusherfire

Ай бұрын

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 Ай бұрын
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 Ай бұрын
yeah man.. its wild.
@MapleRift
@MapleRift Ай бұрын
He wasn’t brutal though? He corrected the mistakes and offered better alternatives
@simvoid4347
@simvoid4347 Ай бұрын
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 Ай бұрын
Me too 😊 so long as they are clearly guard statements and only returning nil or false
@Sadjhj
@Sadjhj 29 күн бұрын
Yeah same
@-zeeb-585
@-zeeb-585 Ай бұрын
PLEASE DO MORE OF THIS AS A LEARNING CODER THIS HELPED TONS
@Hyllested_
@Hyllested_ 27 күн бұрын
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 Ай бұрын
I remember playing this Game a few weeks ago, i knew something was off about it.
@hellohennessy3462
@hellohennessy3462 Ай бұрын
what is off about it?
@nicknameita-yc2ct
@nicknameita-yc2ct Ай бұрын
@@hellohennessy3462 i don't really like the way they make scripts
@hellohennessy3462
@hellohennessy3462 Ай бұрын
@@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 Ай бұрын
@@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 26 күн бұрын
@@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
@Blue-tq3uj
@Blue-tq3uj Ай бұрын
this is great, can you make it into a series?
@Z3SC
@Z3SC Ай бұрын
Can use :Once with the humanoid Died function but should function exactly the same since connections get cleaned when player dies.
@itso6778
@itso6778 Ай бұрын
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
@mr_griffolukegriffiths9166
@mr_griffolukegriffiths9166 Ай бұрын
Would connect the .Died with :Once() to avoid some weird edge cases where died manages to fire multiple times 😊
@begi-dll
@begi-dll Ай бұрын
Would you mind making roblox studio settings / plugins video? I would love to watch it and configure my studio as u have
@okage_
@okage_ Ай бұрын
good video, i did not consider the increased memory from anonymous functions
@llliiimmmeee
@llliiimmmeee Ай бұрын
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"
@llliiimmmeee
@llliiimmmeee Ай бұрын
If u getting bank tho CHASE THAT BAG!!!!
@artem-kt2gh
@artem-kt2gh Ай бұрын
can relate
@yal1621
@yal1621 Ай бұрын
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 Ай бұрын
Can’t you also change the RespawnTime property in the Players service..??
@silly8742
@silly8742 Ай бұрын
@@ExpoM3rker That's what I was thinking, just scrap the code entirely and change the respawn time.
@wedoalittletrolling723
@wedoalittletrolling723 Ай бұрын
@@silly8742 engine-side > any scripted alternative it just you dont get access to the engine side on roblox
@berendberend702
@berendberend702 Ай бұрын
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 29 күн бұрын
@@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
@epixerty
@epixerty Ай бұрын
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 Ай бұрын
never thought about this when making my music system, thanks for the tip.
@epixerty
@epixerty Ай бұрын
@@RedsquareR yeah i made a music system once and had this issue myself
@rud4sek793
@rud4sek793 Ай бұрын
Can you make a video where you show some keyboard shortcuts when writing code?
@MS-lb9yd
@MS-lb9yd Ай бұрын
What’s your studio color settings theme?
@PolarZ0
@PolarZ0 28 күн бұрын
3:00 How do i get the little menu at the bottom right and the size of the part to show up
@artem-kt2gh
@artem-kt2gh Ай бұрын
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()...
@HDWare
@HDWare 29 күн бұрын
What’s your edition settings?
@zxkver8943
@zxkver8943 Ай бұрын
mmm chocolate pudding
@cedricsonaquevido1565
@cedricsonaquevido1565 Ай бұрын
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 Ай бұрын
studio settings and you can change all colors in there
@localsalty
@localsalty Ай бұрын
good video
@MashySob
@MashySob Ай бұрын
how do you change multiple things at once like when changing the variable name
@artem-kt2gh
@artem-kt2gh Ай бұрын
ctrl shift r, or just right click the thing and you will see all the tools
@Billy-gm4wl
@Billy-gm4wl Ай бұрын
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 Ай бұрын
it's just syntax sugar, if you know all the properties and methods of an instance, you don't need it.
@rud4sek793
@rud4sek793 Ай бұрын
what is :: doing in luau?
@Spooky.Studios
@Spooky.Studios Ай бұрын
6:50 or just change the RespawnTime from 5 to 0 lol
@Martanus
@Martanus Ай бұрын
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?
@dumpyloI
@dumpyloI 27 күн бұрын
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 26 күн бұрын
@@dumpyloI im not really sure cuz some ppl said it uses more memory or smth
@dumpyloI
@dumpyloI 25 күн бұрын
​@@Martanus which one, while wait() do or while true do wait()
@AszectiRoblox
@AszectiRoblox Ай бұрын
W vid
@CrazyDoodEpicLeaves
@CrazyDoodEpicLeaves Ай бұрын
3:56 How did you do that, changing all instances of one variable at the same time?
@epixerty
@epixerty Ай бұрын
select anything and press Ctrl+D
@CrazyDoodEpicLeaves
@CrazyDoodEpicLeaves Ай бұрын
@@epixerty That sadly did not work
@2muchtntstudios925
@2muchtntstudios925 Ай бұрын
Hold alt and click where u want ur other cursor to be
@artem-kt2gh
@artem-kt2gh Ай бұрын
ctrl shift r
@epixerty
@epixerty Ай бұрын
@@CrazyDoodEpicLeaves it works for me
@byteblox100
@byteblox100 24 күн бұрын
i will name them with 1 letter
@Tamla1959
@Tamla1959 Ай бұрын
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 Ай бұрын
it is deprecated
@Tamla1959
@Tamla1959 Ай бұрын
@@Fimutsu it's not
@crusherfire1
@crusherfire1 Ай бұрын
@@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 Ай бұрын
@@crusherfire1 ah right
@artem-kt2gh
@artem-kt2gh Ай бұрын
6:25 am i the only one who thought to just change property RespawnTime in Players service to 0?
@RyanEXElol
@RyanEXElol Ай бұрын
Nope..
@jonathan10007
@jonathan10007 Ай бұрын
oh man if you saw my code anything goes
@hike8932
@hike8932 Ай бұрын
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 Ай бұрын
It’s in his channel’s community tab
@Lkrupa
@Lkrupa Ай бұрын
Your never going to make me use task.wait!!!!!!
@crusherfire1
@crusherfire1 Ай бұрын
😔
@real_quandie
@real_quandie Ай бұрын
this game is useless money farm, like fr, it asking for robux to get scripts that you can find in internet
@CRT_YT
@CRT_YT Ай бұрын
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 Ай бұрын
Their code has to be the most laziest code I've ever seen 😭😭
@CreatorProductionsOriginal
@CreatorProductionsOriginal Ай бұрын
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 Ай бұрын
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 Ай бұрын
@@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 Ай бұрын
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 Ай бұрын
@@kai-o-kai key word: most
@kai-o-kai
@kai-o-kai Ай бұрын
@@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 Ай бұрын
ScriptBox is more like a ShitBox imo
@tower9602
@tower9602 Ай бұрын
Oop sucks, return back to functional programming
@kai-o-kai
@kai-o-kai Ай бұрын
Fucking what?
@hinokamitanjiro-ow8cr
@hinokamitanjiro-ow8cr Ай бұрын
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 Ай бұрын
I'm very picky! 🤯
@TheDailyCraft
@TheDailyCraft Ай бұрын
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
The Farlands But in ROBLOX
10:46
Crusherfire
Рет қаралды 143 М.
Roblox Devs, stop misusing :WaitForChild()!
17:13
Crusherfire
Рет қаралды 38 М.
Luck Decides My Future Again 🍀🍀🍀 #katebrush #shorts
00:19
Kate Brush
Рет қаралды 7 МЛН
Homemade Professional Spy Trick To Unlock A Phone 🔍
00:55
Crafty Champions
Рет қаралды 56 МЛН
I’m just a kid 🥹🥰 LeoNata family #shorts
00:12
LeoNata Family
Рет қаралды 16 МЛН
Optimizing my Game so it Runs on a Potato
19:02
Blargis
Рет қаралды 434 М.
I Learned How to SCRIPT in 7 Days | Roblox
11:00
Simjet
Рет қаралды 28 М.
Attacking Hitboxes | Roblox Essentials #2
12:11
Solepsus
Рет қаралды 12 М.
3 Hours vs. 3 Years of Blender
17:44
Isto Inc.
Рет қаралды 3,7 МЛН
10 Tips to Become a PRO Roblox Scripter (ft. @rustysillyband)
22:03
Infiltrating Roblox’s Fake Middleman Scam
18:57
No Text To Speech
Рет қаралды 754 М.
How many visits will immersive ads get me on Roblox?
25:47
Cookie Tech
Рет қаралды 262 М.
how to use OCTREES in your Roblox Game
9:13
Crusherfire
Рет қаралды 10 М.
How pro Roblox developers learnt to script
10:03
AlvinBlox
Рет қаралды 834 М.
The Incredibly Weird History of Natural Disaster Survival
16:18
Nitrolord
Рет қаралды 117 М.
МЕГАЯЩИКИ ВЕРНУЛИ В BRAWL STARS *УРА*
11:28
Поззи
Рет қаралды 652 М.
Ата мені Құпия қорабқа алдап кетті!
24:02
Реальнее чем в жизни ( Bodycam )
14:10
JOHAN
Рет қаралды 963 М.