Any Tips on Learning to Script?

Hey there so I know Roblox In the future will be all scripting. Everything will be code. Before that time comes, I want to learn how to script. I know the basics such as print, values, inserting a brick etc. but I want to dive even deeper. The Roblox Wiki doesnā€™t really explain as good where Iā€™ll understand it, or itā€™s just Iā€™m not thinking of it the right way, or understanding it correctly on what it does.

By any chance do you guys have any tips on what to learn first (besides what Iā€™ve already learned) or where I can find a good learning place, how to actually learn and understand what is being taught to me? Really would love to get into scripting and making my Roblox Dreams come true.

Thanks!

13 Likes

Programming is mainly just logic, which means that anyone can technically be at least decent at it with time. Many learn how to program through online tutorials and the wiki. I highly recommend checking out @Spooks_HDā€™s and @SteadyOnā€™s YouTube channels as they both programming in an effective manner. Another way to learn is to have experience, which you can definitely get from a project, such as a game. As long as you continue to practice and learn, your skill will developer over time.

On a separate note, according to the brand guidelines, itā€™s actually Roblox and not ROBLOX. I know how hard it is to change how you say something but itā€™s better to start as early as you can then to never start at all.

12 Likes

sorry on the roblox partā€¦ and thank you. Iā€™ll edit it now

1 Like

You donā€™t need to say sorry. Itā€™s a very common mistake that wonā€™t be held against you in any shape or form.

4 Likes

Roblox is definitely not ā€œall scriptingā€ and there are a lot of physics based simple games and simulations you can have without using any actual code. The thing is that scripting lets you tell the engine what it should do. Scripting languages are just that, languages. They all have their own syntax, grammar, structure. You use this language to communicate with the engine. In fact, you can even translate it.

for count=1,10 do
    print("Value is "..count)
end
obj.Position = Vector3.new(4,0,0)

iterate count from 1 to 10
output "Value is " with count appended
set the Position property of obj to (4,0,0)

Learning how to script is you essentially learning how to interface with the engine and how to make things happen by typing it out. Another thing is that you might need to understand different fields and different ideas in order to incorporate them. You might, for example, need to take courses in physics or study basic kinematics in order to simulate projectile motion. Outside information can be implemented to make scripting even more powerful. Just know that lines and statements are instructions and commands. As long as you type it correctly and the language supports what youre doing, you can make it happen.

One of the easiest ways to start scripting is to think of basic things in your native language and translate them into scripts. Here is another example:

I want to:
Make a copy of a car
Spawn the car
Put the car at the spawn zone

local car = storedcar:Clone()
car.Parent = workspace
car:SetPrimaryPartCFrame(spawncframe)

Things you do not know how to do can be found on the internet and on many different wikis. You can also join helping discords / groups. There are also many youtube and wiki tutorials to help you get started with newfound understanding of the Lua language and all its grammatical structure.

Other useful posts:

11 Likes

Here are a couple of posts:

Remember this forum has a search feature! :wink:

1 Like

When youā€™re first learning it is easy to see other devā€™s projects and set your own bar too high.

As I mention in my above post, you need to take on very small projects like a lava script or disco ball. These little projects will teach you how to understand loops and events.
Another good one to learn is a time of day script which can help you learn logicical operations

3 Likes

Before I say anything I need to tell you that there is no shortcut when learning how to script

Some people may learn faster than others and it took me 1 year to fully learn most of each endpoint. Like what WingItMan said, donā€™t set your scripting standards so high as youā€™re new.

Print Function

print("String here")

Now you might be asking why do I need "" inside the parenthesis? The reason is to define that youā€™re using a string value. If it was a number value you could just say 1 without using "1".

Now, letā€™s try to print in the console ā€œHello, World!ā€.

Answer:

print(ā€œHello, World!ā€)

Loops

There are multiple types of loops here.

While - do loops

This is the most common loop for you. While [Argument] Do means whatever code you put inside the loop it will keep on running until the Argument Statement is no longer true.
Example:

while true do
 print("Hello!") -- Hello everyone!
 wait() -- I'll tell you why later why you need this
end

Of course, if you keep a while true do loop without a wait() function or a wait system then your Studio would crash as youā€™re trying to loop something over and over in 0 seconds.
Here is an easy wait of adding a wait() inside a while true do loop

while wait() do
 -- Code here
end

For i loops

For I loops have 3 arguments: Starting number, Target Number, Increment (Default 1)

For i loops should be used for times that you need to repeat something over and over a specific amount.
Example code:

for i=1, 5 do -- Count up to 5
 print("This message was said a total of " .. i .. " times!")
end

wait()

The wait() function is to yield the script an X amount of time. If you leave X blank it will wait 0.03 seconds I think. The X must be a number value and it is counted in seconds.

Example:

print("Let's wait for 1 second!")
wait(1)
print("We waited for that long? Like omg #WaitingIsSooooLong")

If Statements

IF STATEMENT THEN
This is when you want to check if a statement is true and want to run code.
Example:

local CanPrint = false

if CanPrint == true then
 print("We can finally print!")
end

ELSEIF

Elseif statements allow you to run multiple if statements inside 1 if function. If the first If statement is not true then it will move onto the next and so on and so on

Example:

local Number = 2
if Number == 1 then
 print("It's 1!")
elseif Number==2 then
 print("It's 2!")
elseif Number==3 then
 print("It's 3!")
end

ELSE

Else will only activate if all IF statements are not true.

Example:

local CanPrint = true

if CanPrint == true then
 print("We can print!")
else
 print("Seems like the party pooper is here")
end

This is a very quick introduction to Lua.
Please reference from a professional video tutorial or the Roblox wiki.
I highly recommend you use the Wiki. If you need further down the line reference code I recommend @alvinbloxxā€™s youtube videos
Tho, what I would reccomend is him explaining more on youā€™re coding i.e. explaining what this part does and why in the video.

15 Likes

Reading and learning is useless if you do not practice.
Make a place, insert a script and start doing magic.

Even if youā€™re going to start with simple print(9+10), try something more advanced and harder everytime you complete something.

Trial and error.

2 Likes

Trial and error indeed. I started out (~2010) by taking free models and reverse engineering them although now I probably wouldnā€™t recommend free models for learning. I would do a bit of reading then a lot of trial and error.

3 Likes

Most free models now are outdated and wonā€™t work properly with the forced Filtering Enabled.

1 Like

Plus a lot of FMs have viruses in them that lag out your place.

But this video will show you how to remove unwanted scripts and stuff from free models.

1 Like

Look at other peopleā€™s code and try to figure out what it does then try to recreate it yourself.

1 Like

In terms of resources I would go heavily with the ROBLOX Developer Hub and go little on video tutorials(unless made by ROBLOX). A channel I would recommend is AlvinBlox. In my personal opinion, heā€™s one of the best ROBLOX Development channel.

1 Like