# Need help on learning

Hey guys, I’ve been on and off with scripting since I always lose motivation but this time I really want to get into it. I’m still a beginner but I know basic stuff like functions, events, etc.

I’ve been searching up on Youtube “How to make a simulator” hoping to gain some knowledge but the way they are teaching it are way too advanced and have some code that can be coded way easier.

What I’m asking is… what should a beginner scripting like me do to learn more? Should I keep watching tutorials? Mini projects? Etc. Please and thank you!

Solve problems you already know how to solve (on paper) using code. This is a good way to gain confidence. Some problems from geometry are good choices as you will often need to solve geometry problems for game programming.

Also, look at other peoples code and try to understand why they chose to design it that way. Everyone has a different background that influences how they decide to write anything, treat it the same way as reading a fiction book.

1 Like

You Should Learn the basic function in Lua

For Example:

``````-- Standard One Line Comment

--[[ Multi-Line Comment
OMG THIS IS A MULTI LINE COMMENT, I CAN TYPE MORE THAN ONE LINE
--]]
LOL -- What not to do

---[[ To Disable a Multi-Line Comment, add another Hyphen, This thing: -
local Var = "Hi"
--]]
``````

Variables:

``````GlobalVariable = nil -- You set a Global Variable to nil if you want it to have no value
local LocalVariable -- Here you dont add anything
--[[
Global variables Can be used anywhere

Local Variables can be used within Range of the script
(Ex: if its inside a function, It can only be used inside the function)
--]]

local String = "Hello" --A string is usually Words, or Letters, and even Sentences
local Integer = 12  -- An Int is just Numbers
local Boolean = true -- A Bool is pretty much a true or false statement

wait(1) -- Waits for a certain amount of time (Deprecated)
--(Deprecated Means, No longer used, No Longer Supported, and is planned to be removed)

task.wait(1) -- Better at waiting (No throttling)

local function Example() -- a Function, runs code when called,
print("Hello!")
end

Example() -- Call the function by using its name, in this case "Example"
``````

Loops:
When running loops, They will run until they are told to stop
There are 3 Main Loops, `while`, `repeat until`, and `for`

``````Looping = false
while Looping == true do -- a while loop runs for certain conditions, if the condition is not met, it wont run
-- NEVER FORGET TO ADD A WAIT, IT WILL CRASH YOUR SCRIPT
end

repeat
task.wait(1) -- Waits for 1 second before looping

until -- Repeats until a certain condition is met
``````

A `for` loop is the most complicated, It can Vary from Easy, to Confusing, Example of uses:

``````-- Simple Use
for index = 1,10 do -- Will run 10 times
print(index) -- Prints the Number the Loop is currently at
end

for _,v in pairs(workspace:GetChildren()) do

if v:IsA("Part") then
v:Destroy()
end
end
``````

What Not to Do

• Never name a Variable the same as a function, it will break the function the next time you use it
``````print = 12 -- Never do this

print(12) -- Running this will break since it has been assigned to something else
``````
2 Likes

You can experiment with functions that u no know, and later look videos of it.
example:

how while works?
how use for loops?
how to use events?