I don't know when I should use or what to use during scripting

I’ve already been taught on how to do functions, events, variables and almost everything to scripting. My only problem is, knowing when to use these things. I don’t know how I should use them when making something like a RTS movement system, does anyone have a semi-solution or tips on how to know what to use?

When you initialize a variable what you are doing is:

You tell the compiler or interpreter to make a space in the RAM where the type of the value and the value itself are stored (this space is known as an “object”)

e.g. local b = 5

b becomes a pointer (a.k.a reference) to that memory address you created.

that’s why when you say print(b) the output display 5, it is indirectly accessing the value stored in that memory address.

why does it also store a type?

because the computer needs to know what to do with the value.

by storing the type ‘number’ (or ‘integer’ in other programming languages), the computer knows what to do with that value:

print(b + b)

the output prints 10

some really crazy and wild assembly code is going on behind the scenes, comparing their types, if their types mismatch, an error is thrown saying something infamous like: you can’t add text with number. If the types don’t mismatch, it can successfully add the value on the right to the value on the left

this is when you should also be taught binary without it you wont understand the other concepts. You will merely learn the syntax.

binary is a sequence of 0s and 1s e.g. 01010101

with this sequence we can represent many types of data.

a sequence that has only 8 digits (00000000) is said to be 1 byte (8 bits long)

a bit is either 0 or 1
1 byte are 8 digits that are either 0 or 1

if the digits is only 3 bits that is still 1 byte because programming languages prefer to interpret bytes as fixed digits 8, 16, 32, 64

five in binary would be 101, in a high level programming language it’s 00000101

the computer who only understands machine language would do a lot more behind the scenes than simply merging the binary numbers

but it’s thanks to the numbers you provide the computer through a high level language that it can interpret what it should do next.

I highly recommend not learning luau as your first programming language, you will only be taught the syntax and will only learn to code extremely naively.

I recommend this source as learning material: www.learncpp.com or C Pointers

Either you way, even though programming is complicated, it can be extremely fun and fulfilling once you learn the fundamentals.

1 Like

There is no unanimous advice on what you should use and in which cases. Your question is too global to be answered.

But it helps to start by breaking down the mechanics you want to implement.

Also it’s kinda basic programming but functions are great for organizing your code and encapsulating specific behaviors, like moving a unit or updating its status. Use events to trigger responses to player inputs or game state changes, like when a unit reaches a destination or when a player selects multiple units. Variables are essential for storing the state of your units, such as their positions, health, and commands.

As you work through the development, think about the flow of your game: when an action occurs, what should respond to it? This can guide you in deciding when to use each scripting element. Prototyping your ideas quickly can also reveal how these components fit together, helping you learn through experimentation.

Also I don’t see why starting with Lua is a bad idea. You have to start somewhere and starting with C is like jumping off a cliff.
Most people who start with C are just fed up with computers, you have to start with an easier concept and then see how it works in detail.

Have you ever had a low-level computer science course? No teacher starts with such complicated concepts, especially when stated in a chain like you did.

Python is the most common language people learn to code with, is it better than Luau? Not at all, we don’t do the same things with it, that’s all. This means that, even if Luau is not the best choice, it’s not a bad one anyway.

However, I agree that at some point, learning C or his concepts (eg. how memory works as you explained) can only be positive.

I understand your reply and it makes completely sense. However, my system to learn is a bit different, I do like to jump in the cliff and be eaten by the wolves living in there, because, if i manage to survive i can alert the tribe that we are in danger.

the CS50 course starts by saying that most of the students that take CS50 have never coded before, and then they start explaining memory and binary right off the bat. I think learning the surface before the layer can give a much better comprehension of what is to come after.

for example, knowing about memory allocation can lead to defining variables which can lead to references and pointers making variables and references simultaneously easy to comprehend leading to many “eureka” moments.

surface in this case would be the fundamentals needed to learn the layer which would be the syntax of the programming language.

that way, learning one or two programming languages is the same as going to buy bread; you purchase the one you like the most.

You can get ideas or research them from multiple sources. This is especially true for something complex like RTS movement made of multiple components such as the unit selection gui, pathfinding, and then the simulated physics movement.

You can start with a popular game outside of Roblox and learn of a concept known as “Path finding” “A star” and all these unknown terms.

Group Movement | A research about implementing group movement in RTS using flocking behaviour.

Then you can bring this knowledge into Roblox by then search on the docs for “pathfinding” then start there. With what is available within the engine and the tutorials provided with built in character physics movement as well.

https://create.roblox.com/docs/characters/pathfinding

Then you try it out, see if it works and so on which is a pretty lengthy process. As you said it is a semi-solution and not a 100% perfect solution.

1 Like

Thank you for the information.