Questions About Scripting

Well, I Have Some Questions About Scripting And They Are:

  1. Should I Think About What Im Scripting? Like I Want To Make A Kill Brick So I Think:
    “Lets Check If Hit Parent Have A Humanoid And If So Damage It” Or I Just Script It Without Thinking Alot?

  2. What Exactly Is Spaghetti Code? A Code That Is Too Complex To A Simple Thing? A Code That You Dont Think How You Code It? And How I Prevent That?

  3. How Many Times Should I Use Functions, Comments And Modules? Alot? When I Really Need?

And The Last One.

  1. How Do I Script Better In General??
1 Like

Spaghetti code is when the code is complexed then it should be, not easily able to adapt to change, or there is different developers making different things that no one can understand the code. This code could also be code that uses deprecated methods to do something (Deprecated is code that is still around, but Roblox no longer support it, and it can be removed any day)

I use a lot of functions to simplify my tasks, and I leave comments so if future me needs to read script, and make changes, I can make it easily.

I script with a lot of thinking behind it. I would encourage you to think as it atleast gives you some starting points.

1 Like
  1. Yes. Absolutely. It’s always a great idea to think before scripting, I used to open and start writing code then I end up making a big mess while forgetting some parts here and there, after starting to plan first, I don’t only include everything I wanted, I also make it more arranged. In simple words, it gives you a clear plan, and you know the saying “a goal with a plan is just a wish”. So stop wishing and start planning.

  2. Spaghetti code is used to describe code that is error-prone, time-consuming to work with, and can lead to a variety of issues. Making a change can cause problems in another unrelated parts, it’s hard to understand what the code needs and it’s so hard to edit it when needed.

  3. The use of functions, comments, and modules in your code should be based on principles of code readability, maintainability, and reusability. Functions should be used for code that will be reused and should make one small thing, not overly small but small enough that it can be used in different scenarios while being specific to one thing. Comments are to explain what functions to do or what complex pieces of code do, personally I don’t think they should be used in other than that, very controversial though. I like using modules A LOT, and I really mean A LOT. They are so great for organizing, splitting code, classes, making functions that are used across scripts, and so on. That doesn’t mean everything needs to be a module though.

  4. There isn’t a specific way to script, it’s very unlikely to see 2 programmers writing the same exact code. It all depends on you, so just write and you will normally see what’s good and what’s bad, the dos and don’ts, etc. It’s a matter of time till you get the hang of it


Good luck on your journey.

3 Likes

Thankssssss I Will Try Your Tips :slight_smile:

1 Like

There is something I can add to #1. Thinking is great. It will help you make more organized code from the outset. Just don’t overthink. For some people (like me) it can be rather easy to think too much about the perfect solution instead of going with a good enough solution. As long as if your code is maintainable, your solution is likely good enough. You tend to understand the problem better after having already coded it too, so if you do need to go back and make changes after, you’ll have a more solid idea of what needs to be made better. Note this only applies to complicated things, if it’s simple you should try to think through everything to make your code robust. Well I guess complexity isn’t the real metric, but rather the balance of time consumption to outcome.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.