Learn RblxLua Part 2 (Starting To Code)

THIS IS PART TWO OF LEARNING LUA PLEASE START AT PART ONE

Now that we know about clients and servers, let’s start learning about coding

I will be showing examples of everything.

This thread includes:

  • Prints
  • Comments
  • Variables
  • Changing Part Properties Through Script

Prints

Prints are very basic, to print is to display a message in the output, it is only visible to the server. Prints can also be shown in the Developer Console, you can only use it when you are playing as the client. Here’s an example of a print

print("This message is only shown in the output.")

Output Result

12:00:52.594 This message is only shown in the output - Server - Script:1

Developer Console

Comments

Comments are very basic, you use comments in a script, comments are not put out in the output like print, comments are only visible to the server, to use comments put – and type your comment. You can use Comments for organizing for example:

local variable = print("Hello World") --Prints Hello World

variable --Variable Is Being Called

This can be useful if you backtrack to your scripts or if you are making a free-model / open-source.

Variables

Variables are very important! You will use them in every script you program, variables are used to hold information, for example, you can store a part inside a variable:

part = game.Workspace.Part

Using variables, I stored the part. To make a variable you first name your variable, then you add an equivalent sign to show what it is equivalent to, so the part is equivalent to game.Workspace.Part which leads to the actual part stored in the Workspace. To call a variable, you just say its name for example:

part = game.Workspace.Part

part

this obviously doesn’t do anything because we are specifying the part’s place in the workspace, we will be using variables soon in this thread.

Part Properties

To see the part properties you just press the part and look in the properties, the properties in the part is what you can change in a script.

Properties Screenshot

Let’s say you want to change your part into another color, we would first

store the part in a variable, then call the variable and change it by using the equivalent sign. Example:

part = game.Workspace.Part

part.BrickColor = BrickColor.new("Really red") -- This is changing the color to red

You can change other things as well

part = game.Workspace.Part

part.Anchored = false --This is unanchoring the part.

This changes if it’s anchored or not.

part = game.Workspace.Part

part.Transparency = 2

This changes the Transparency

My point is, you can change a part’s properties using a script.

3 Likes

Hey, I like this tutorial, maybe make a game based off of this documentation?

Sure, I can definitely do that!

Ok then. Can you dm me pls???

I feel like this tutorial series isn’t particularly great due to how you jump around without explaining certain things.

Take this for example:

You should be explaining what a boolean is before using it in code. It’s like expecting someone to do algebra without knowing how to do basic concepts of maths like multiplication (obviously hyperbole but it should simplify my point).


This is wrong, you can call print() on the client and it will show up on the console (it defaults to client unless you are playtesting from the servers pov).

1 Like

Never mind, don’t worry about it.

thanks for the construction criticism, I am forecasting what I was going to put for part 3, for the second part you are right, I didn’t think of talking about a console if you had a output, maybe for you it was necessary but for me it was unnecessary, the console log is basically the output.

Also for the developer console, I wanted to point that out in part 3, for changing values with developer console, so I don’t intend putting that in

Do you have anything else to show for examples? I also feel like you were cherry picking

1 Like

No not really, my alt is trinomology, I use it for storing models and for group holding

You should change it from Learn Lua to “Learn RblxLua” or “Learn LuaU”

1 Like

You are right, I didn’t really stick to the topic