how to write CLEANER code - Roblox Studio

  Рет қаралды 10,722

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...
Ever wanted to learn Roblox Studio & scripting? Check out my course:
bit.ly/LuaScri...
Use code DEV2024 for 33% off!
My linktree:
linktr.ee/crus...
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!

Пікірлер: 96
@Tkdriverx
@Tkdriverx 2 ай бұрын
6:45 The way to improve this code is to completely remove it and set Players.RespawnTime to 0. No code necessary.
@ThatGuyNamedBender
@ThatGuyNamedBender 4 ай бұрын
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 4 ай бұрын
yeah man.. its wild.
@MapleRift
@MapleRift 4 ай бұрын
He wasn’t brutal though? He corrected the mistakes and offered better alternatives
@simvoid4347
@simvoid4347 4 ай бұрын
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 4 ай бұрын
Me too 😊 so long as they are clearly guard statements and only returning nil or false
@Sadjhj
@Sadjhj 4 ай бұрын
Yeah same
@somenerd8139
@somenerd8139 2 ай бұрын
Yeah, there's nothing wrong with doing it.
@llliiimmmeee
@llliiimmmeee 4 ай бұрын
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 4 ай бұрын
If u getting bank tho CHASE THAT BAG!!!!
@artem-kt2gh
@artem-kt2gh 4 ай бұрын
can relate
@-zeeb-585
@-zeeb-585 4 ай бұрын
PLEASE DO MORE OF THIS AS A LEARNING CODER THIS HELPED TONS
@yal1621
@yal1621 4 ай бұрын
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 4 ай бұрын
Can’t you also change the RespawnTime property in the Players service..??
@silly8742
@silly8742 4 ай бұрын
@@ExpoM3rker That's what I was thinking, just scrap the code entirely and change the respawn time.
@chibisayori20
@chibisayori20 4 ай бұрын
@@silly8742 engine-side > any scripted alternative it just you dont get access to the engine side on roblox
@berendberend702
@berendberend702 4 ай бұрын
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 4 ай бұрын
@@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
@nickname2010ita
@nickname2010ita 4 ай бұрын
I remember playing this Game a few weeks ago, i knew something was off about it.
@hellohennessy3462
@hellohennessy3462 4 ай бұрын
what is off about it?
@nickname2010ita
@nickname2010ita 4 ай бұрын
@@hellohennessy3462 i don't really like the way they make scripts
@hellohennessy3462
@hellohennessy3462 4 ай бұрын
@@nickname2010ita 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 4 ай бұрын
@@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 3 ай бұрын
@@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
@Z3SC
@Z3SC 4 ай бұрын
Can use :Once with the humanoid Died function but should function exactly the same since connections get cleaned when player dies.
@itso6778
@itso6778 4 ай бұрын
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 4 ай бұрын
Would connect the .Died with :Once() to avoid some weird edge cases where died manages to fire multiple times 😊
@begi-dll
@begi-dll 4 ай бұрын
Would you mind making roblox studio settings / plugins video? I would love to watch it and configure my studio as u have
@Hyllested_
@Hyllested_ 3 ай бұрын
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!
@okage_
@okage_ 4 ай бұрын
good video, i did not consider the increased memory from anonymous functions
@rud4sek793
@rud4sek793 4 ай бұрын
Can you make a video where you show some keyboard shortcuts when writing code?
@Blue-tq3uj
@Blue-tq3uj 4 ай бұрын
this is great, can you make it into a series?
@realrunnow
@realrunnow 2 ай бұрын
If they were free, but they want you to pay for badly put tougether, which to me feels extremely scummy. Its like someone who releases a game stitched out of asset store assets or sketchfab models, calls it a day and puts a 10 dollar price tag on it
@artem-kt2gh
@artem-kt2gh 4 ай бұрын
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()...
@zxkver
@zxkver 4 ай бұрын
mmm chocolate pudding
@PolarZ0
@PolarZ0 3 ай бұрын
3:00 How do i get the little menu at the bottom right and the size of the part to show up
@Martanus
@Martanus 4 ай бұрын
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 3 ай бұрын
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 3 ай бұрын
@@fardmonkegaming im not really sure cuz some ppl said it uses more memory or smth
@fardmonkegaming
@fardmonkegaming 3 ай бұрын
​@@Martanus which one, while wait() do or while true do wait()
@somenerd8139
@somenerd8139 2 ай бұрын
sorry bro but if that actually uses more memory it would be the most MINISCULE amount possible, do whatever you like better.
@MS-lb9yd
@MS-lb9yd 4 ай бұрын
What’s your studio color settings theme?
@cedricsonaquevido1565
@cedricsonaquevido1565 4 ай бұрын
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 4 ай бұрын
studio settings and you can change all colors in there
@Noon1263
@Noon1263 4 ай бұрын
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 4 ай бұрын
it is deprecated
@Noon1263
@Noon1263 4 ай бұрын
@@Fimutsu it's not
@crusherfire1
@crusherfire1 4 ай бұрын
@@Noon1263 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)
@Noon1263
@Noon1263 4 ай бұрын
@@crusherfire1 ah right
@MashySob
@MashySob 4 ай бұрын
how do you change multiple things at once like when changing the variable name
@artem-kt2gh
@artem-kt2gh 4 ай бұрын
ctrl shift r, or just right click the thing and you will see all the tools
@HDWare
@HDWare 4 ай бұрын
What’s your edition settings?
@Spooky.Studios
@Spooky.Studios 4 ай бұрын
6:50 or just change the RespawnTime from 5 to 0 lol
@Billy-gm4wl
@Billy-gm4wl 4 ай бұрын
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
@chibisayori20
@chibisayori20 4 ай бұрын
it's just syntax sugar, if you know all the properties and methods of an instance, you don't need it.
@somenerd8139
@somenerd8139 2 ай бұрын
Whenever you call a function in your script, the : (type) will show up in the function description, so you don't need to memorize what kind of variables your functions want.
@artem-kt2gh
@artem-kt2gh 4 ай бұрын
6:25 am i the only one who thought to just change property RespawnTime in Players service to 0?
@RyanEXElol
@RyanEXElol 4 ай бұрын
Nope..
@Avysilvasan
@Avysilvasan Ай бұрын
try improving "print("hello world")" 😈😈
@CrazyDoodEpicLeaves
@CrazyDoodEpicLeaves 4 ай бұрын
3:56 How did you do that, changing all instances of one variable at the same time?
@CrazyDoodEpicLeaves
@CrazyDoodEpicLeaves 4 ай бұрын
@@epixerty That sadly did not work
@2muchtntstudios925
@2muchtntstudios925 4 ай бұрын
Hold alt and click where u want ur other cursor to be
@artem-kt2gh
@artem-kt2gh 4 ай бұрын
ctrl shift r
@rud4sek793
@rud4sek793 4 ай бұрын
what is :: doing in luau?
@hike8932
@hike8932 4 ай бұрын
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 4 ай бұрын
It’s in his channel’s community tab
@byteblox100
@byteblox100 3 ай бұрын
i will name them with 1 letter
@somenerd8139
@somenerd8139 2 ай бұрын
wild byteblox encounter
@CRT_YT
@CRT_YT 4 ай бұрын
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
@real_quandie
@real_quandie 4 ай бұрын
this game is useless money farm, like fr, it asking for robux to get scripts that you can find in internet
@localsalty
@localsalty 4 ай бұрын
good video
@jonathan10007
@jonathan10007 4 ай бұрын
oh man if you saw my code anything goes
@AszectiRoblox
@AszectiRoblox 4 ай бұрын
W vid
@CreatorProductionsOriginal
@CreatorProductionsOriginal 4 ай бұрын
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 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 4 ай бұрын
@@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 4 ай бұрын
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 4 ай бұрын
@@kai-o-kai key word: most
@kai-o-kai
@kai-o-kai 4 ай бұрын
@@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.
@VectoorX
@VectoorX 4 ай бұрын
Their code has to be the most laziest code I've ever seen 😭😭
@Teknifiant
@Teknifiant 4 ай бұрын
ScriptBox is more like a ShitBox imo
@tower9602
@tower9602 4 ай бұрын
Oop sucks, return back to functional programming
@kai-o-kai
@kai-o-kai 4 ай бұрын
Fucking what?
@Lkrupa
@Lkrupa 4 ай бұрын
Your never going to make me use task.wait!!!!!!
@crusherfire1
@crusherfire1 4 ай бұрын
😔
@hinokamitanjiro-ow8cr
@hinokamitanjiro-ow8cr 4 ай бұрын
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 4 ай бұрын
I'm very picky! 🤯
@TheDailyCraft
@TheDailyCraft 4 ай бұрын
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
Roblox Devs, stop misusing :WaitForChild()!
17:13
Crusherfire
Рет қаралды 66 М.
you SUCK at organizing scripts... Let's fix that!
13:12
Crusherfire
Рет қаралды 18 М.
哈莉奎因怎么变骷髅了#小丑 #shorts
00:19
好人小丑
Рет қаралды 51 МЛН
отомстил?
00:56
История одного вокалиста
Рет қаралды 7 МЛН
I Made a Roblox Game in 100 Hours...
11:26
reyn
Рет қаралды 333 М.
What Roblox Doesn't Tell You | Roblox Studio
9:38
Stewiepfing
Рет қаралды 28 М.
How To Make CHAT TAGS in ROBLOX STUDIO
5:44
Lennert
Рет қаралды 6 М.
Type Annotation in Roblox Studio!
28:47
Crusherfire
Рет қаралды 7 М.
The Farlands But in ROBLOX
10:46
Crusherfire
Рет қаралды 147 М.
METATABLES | What are they and how can we use them?
18:40
Crusherfire
Рет қаралды 21 М.
Roblox Code Review: Miner's Haven
16:59
foshes
Рет қаралды 76 М.
Programming Rarity is Harder Than You Think
12:31
ByteBlox
Рет қаралды 267 М.
This Is What 2 Years Of Scripting Looks Like
45:59
Ludius
Рет қаралды 28 М.