Scripting Manual for everyone

Hi, i’m roblox developer for 6 years, i’m started in 2017, first i wan’t to make robux, but it was too hard for me, i’m was a noob, there was nothing on youtube to learn, i don’t know dev forum. Now after this years of passion and learning, i’m wan’t to do something more , i’m started programming in C++ laungage that is better. But before that, i wan’t to share my knowledge to every noob like me 6 years ago, and i wan’t to make real Programmer.

Note: I’m not good at english, i’m from Poland, and i can make a mistakes with times and other things, please don’t mind that, i’m sure you can understand me.

Note: I’m will write this tutorial like book, soo lesson after lesson, and please make sure you know how to use roblox studio , and it’s basics, now, open output, explorer and propertiess, and insert your first script.

Topics: – some of topics are planned, i’m slowly writes this, if you are interested in something there, leave a comment, i will try to write this topics early
1. Print() and Warn() functions
2. Variables and math operations
3. Usefull things to use
4. Manipulating Propertiess
5.Loops: While, For, Repeat
6. Events: Touched and Changed
7. Arrays and Tables
8. Making Systems
9. Services
10. Operators
11. Filtering Enabled
12. Detecting Components: GetChildren(), ChildRemoved(), ChildAdded()
13. Leaderstats
14. Tools
15. Local Scripts Basic
16. Math Functions
17. String Functions
18. Data Storing
19. Optimization Guide
20. Physics: Velocity and Body Movers
21. Raycasting
22. Path Finding Service
23. Upgrading Code
24. Advanced Loops
25. LERP - Linear Interpolation
26. Bézier Curves
27 Tweening.
28. Procedural Generation
29. Angle Calculation
30. CFrame: Advanced
31. Collection Service
32. Run Service
33. Tick() and Clock()
34. Advanced Data Stores
35. About Inventory System
36. About Gun System
37. About Grid Building System
38. Optimized Bots
39. AI for Animals/Mobs
40. Generating Shapes
41. About Loot System
42. Functions for effects
43. Corountines
44. Tips for PRO Scripters
1. Output: Print() and Warn()

print("hello world")

Okay, soo after you created script, you see this word, this is the basic function called Print(), it prints text on output after running. Remember that this function is the best debugger for future projects, use it in learning scripts, for finding bugs and for informations.

warn("there is an error")

Warn is printing, but it's make to use when we wan't to show error, i will explain this in the future, you can use warns of course, but prints is better for that.

2. Variables: Basic Data Types

On math lessons, you have algebra where you have a letters that are values, this is variables, a letter or text that are value, for example we have number a that is equals to 5 for example.

-- this is comment, use it to describe script or mark something
local a = 5 -- this is a integer, a number without fraction
local b = true -- this is boolean, a true or false value
local c = 0.5 -- this is float, it's number with fraction
local d = "string" -- this is string, a text value
local e = nil -- this is nill value, it's equals to nothing
local f = {5,true,"text"} -- this is array, a group of numbers, strings or booleans

--[[
this is how you can create comments for multi lines
]]

as you can see we have a lot of variable types, don't worry, this is the easiest ones, now we moving to our first working

local x = 2
local y = 3
local z = 4

-- we defined our integers, soo now we can do our calculations

local a = x+y+z -- we adding integers to each other
local s = x-y-z -- we substracting integers from each other
local m = x*y*z -- we multiplying integers 
local d = x/y/z -- we dividing integers

print(a,s,m,d) -- now we printing every calculation we made


print("Sum is "..a) --[[when we adding two dots after or before
string, we can concentate it with integer or boolean]]

print("X*Y is equals to: "..x*y ) - -example

This is everything for today, i’m told that this is beginning of my manual,
if you are more advanced and you wan’t tutorial about some things, you have to wait or
find another tutorial, you can link tutorials in comments, soo everyone can learn from they

Thanks you for this lesson. Good luck at making your first steps in scripting.

3. Usefull things to use

Now we learn some usefull things like how to delay beetween functions and basic
calculation function.

print("Hi")
wait(1) -- we waiting 1 seccond
print("Hello, What's up?")
wait(1)
print("I'm passed exams")
wait(1)
print("Nice")

This dialogue that have no sense are example of using wait, of course you will use this for almost everything, if you wan't to wait minutes or hours, you need to transform secconds like this:

local hours = 5 * 60 * 60 -- we wan't to wait 5 hours soo we doing this

As you can see, this is a quick conversion for people who don’t know how to do this

Now it's time for calculation functions, it's the easiest one, and the most important

local a = 5
local b = 10

local function Calculate(x:Number,y:Number)

return x * y -- return is something like result, soo we sends this number
end

local result = Calculate(a,b) -- calling function
print(result) -- printing returned variable

This type of functions are common ones, they will help you to sort your code and make calculations, or run something like laser shoot or animation

Thank you for today’s lesson, please tell me if i helped you, it’s important for me because i wan’t to help scripters, advanced and beginners

4. Manipulating Propertiess

Hi, this is day two of my tutorial, firstly i wan’t to talk about what to do for better experience with programming in any enviroment.

  1. Make breaks if you bored, or you can’t figure what to do
  2. Make things that are graphically fun, and easy to see. Maybe explosion effect?
  3. Often go to the park or forest and breathe fresh air, this will help your mind
  4. Don’t give up, if you don’t believe in you, you do nothing

Okay, soo now it’s time for our lesson

local Part = Instance.new("Part") --[[instance.new intalling new object 
via classname]]

Part.Parent = game.Workspace -- setting part's parent to workspace, to see it

Part.Anchored = true -- making part anchored via script, use booleans

Part.CanCollide = true -- default is true, use boolean to change collision

Part.CastShadow = true -- default is true, makes shadows visible or not

Part.BrickColor = BrickColor.new("ReallyRed") --[[setting brick color
to part via color name, i prefer to use color3 because you have more
freedom of what you doing]]

Part.Material = Enum.Material.Neon --[[Enum is roblox data library, there is easing styles,
 materials and many more things, i will explain this in the future]]

Part.Color = Color3.new(255,255,255) -- using RGB to set new color 3

Part.Position = Vector3.new(0,10,0) --[[Vectors are positions 
in every dimmension, in Vector3 we have X, Y and Z axis
Vector3.new is basic function that creates new vector in the world]]

Part.Size = Vector3.new(4,4,4) --[[Size is also vector, but there is distance 
in every direction, remember that is simetrical to other soo if we have size X of 4, we have 2 in one direction]]

Part.Name = "Brick" -- a string that is name of part, you can use this name in the future

Part.Transparency = 0.1 -- a value that represents transparency of part, from 0 to 1

Thats all for today’s lesson, i’m got a tip to write english more correctly, heh :confused: soo,
i will try to do that in the future, i’m think you learned something, thanks you for reading
remember to leave a comment, bye!

5. Loops: While, For, Repeat

Hi, soo this is fifth topic, now we moving into loops, three basic loops.

local condition = true -- for showcase
while condition == true do -- while loop running when given condition is true

print("spam heh...")

wait(0) -- don't forget to add this, else you got error and studio crash

end

While loop is replacement for run service, if you wan't to make something look good, but don't like to lag game, this is for you

local condition = true -- for showcase, again
local index = 1 -- for showcase, number that we will scale up

repeat 

print("MORE SPAM") -- spam, i don't like it
index += 1 -- fun fact, you can do this to add value to existing value
wait(1) -- don't forget to add this, or you know... crash
until index > 5 -- our condition, if index will be greater than 5, the loop will stop

Repeat loop isn't used as often as while or for, but it's good for people who wan't to do something like automatic shooting or other things, i don't use it personally

for i = 1, 10 do --[[ for loop is the most used in scripting, 
it's something like a scanner that reads list from A to Z
print(i) -- every time, i will be bigger value, and at the end,
 i = 10, because we set that i = value from 1 to 10, this is complicated]]

if i == 10 then -- condition for check if loop ends,prevent many bugs
break -- we stopping loop absolutely, soo it will be destroyed
end
end

Soo, this is everything for today’s lesson, in the next lesson i’ll explain many new things, like conditions and events, soo be patient and read slowly to get as much knowledge as you can, good luck and goodbye!

6. Events: Touched and Changed
Sorry for long time of no responsing. Now it’s time for functions connected to events, let’s start

local V= workspace.TestValue -- defining int value inside workspace

V.Value = 5 -- setting V's value to int 5

function OnChanged()
if V.Value ~= 5 then
print("changed!")
end
end
-- when V parameter changes, the event fires and then binding to function
V.Changed:Connect(OnChanged) -- connecting event .changed to this function

This is changed event, good for coin visualization in gui or detecting propertiess change

local Part = workspace.TouchPart -- our part that we'll collide with

Part.Touched:Connect(function(hit) -- this is another way to fire event
-- hit is variable that this function gives, you can read this in code hint
local hittedPart = hit -- this is hitted part
if hit.Parent:FindFirstChild("Humanoid") then -- this is formula for detecting if something is a Npc, simply detect if part parrent (character parts parent is always character) finds humanoid
hittedPart.Parent.Humanoid:TakeDamage(20) -- deals 20 hp to humanoid that touched part

-- maybe add debounce or table debounce, or else  you have something like...
-- super spam, yea
end



end) -- remember to add bracket at the end

This is all, sorry for that content, but i’m tired and it’s hard to write this, i’m hope i’ll do this mission. Thank for your help and motivation. Bye :raised_hand_with_fingers_splayed:
7. Arrays
Sorry for long time of no responce, i’m back. Soo this topic is easy, simple and very usefull, let’s dive into it.

local array = {"a",1} --[[Arrays contain a data like booleans,
 numbers or strings. you can use then in loops or maybe make a list of 
weapon stats]]

arrays can be used to make a lot of things easier, this is also data type

local array = {}
local falsearray = "array"

-- now we detecting if something is an array, for technical reasons for example

if type(array) == "Table" then -- type and typeof return strings if something is given class
print("check.")
elseif type(falsearray)== "Table" then -- falsearray is string, soo condition will return false
print("falsearray is an array :}")

end

Now we can move to loops section of this topic and usefull things to know

local array = {["Apple"] = {"A","B"}} -- you can name arrays by typing ["Name"]
-- Moreover you can put tables in tables

for i, v in pairs(array) do -- don't add loop break to this, because index is not number!
if i and v then
print(i,v) -- index is value name, v is value itself
end
end

Soo, arrays and tables are data type that holds data and variables, you can use it in almost everywhere. This is everything for this lesson, sorry for no responsing, but slowly i’ll make this tutorial and bring it to the finish. See you later, bye!
8. Making Systems
Note: sorry for that, i have no time and i don’t script in LUA much, this is maybe the last part of manual…

Systems are important, they are integrated scripts that works together making some function inside your game.

This is more about talking, but i’ll give you some tips

To make system you should know what you wan’t to do, remember that you should know basics of code, from loops and conditions you can make almost everything, you only must know how!

Tips:

1 Use module scripts: modules are usefull to store arrays and functions that can be easily accesed from every part of your game, this way you can save time and optimize your code a little to make things required for system's work

2 Optimize your code, this can be done in various ways, for example don't make script in every brick that will make players off, instead get all parts this type into array or tag it and then use .touched event on every. Game now need to load your script once, not 500 times soo this will be 500x less work for server

3 Make research, this includes testing basic use of code, like how to manipulate strings or maybe more advanced data store

4 Plan your systems, make elements of it then combine them together to create a working system

5 Work together, if your friend know how to script, they can make some elements of code, you can make another and then make everything faster

6 if you work with friends, check your mistakes to fix them, this is better than 10 hours of debugging xd

this is end, i have less time now, this is maybe the last part, sorry.

37. About Grid Building System

Soo, this is large skip, if there aren’t any previous topic, please wait.
Why i’m writing this, because this was my nightmare, i figured how to do that, but
you know, basic solution sometimes is pain.

but now, let’s start

  1. Important Things

soo first, what we need?

  • System that checks if number is even or not
  • Remote Event that sends info about our mouse
  • Security breaks in our loops
  • Correction System
  • Grid Calculator
  1. Where to start?

personally, every time i’m doing things like this i starts with local side, and then i moving into server, but this time is different, first make raw systems, like function that calculates grid for example values , script that checks if number is even or not and basic correction system. Then try to connect each piece of code into one bigger script.

3.Why Relative GPS is better?

Because you can make system relative to certain part, like maybe building zone.
Moreover you can make saving better, of course if you wan’t.

  1. Example of functions:

Note:"i will prepare it for you, wait some time :smile: :smiley:

27 Likes

There are many scripting manuals here, even in the devforums, back in 2017, there isn’t much, now there is a lot

5 Likes

You know, when i was young, i can’t find manual, now i’m writing this for everyone, it’s my final project on roblox, i wan’t to tell about basics, and more advanced things, like how to make grid building system or maybe basic TPS system

6 Likes

Don’t worry, things like this are always welcome!
I suggest something tho, try using the translator as I had a bit of a hard time understanding, but it was understandable tho

Also, don’t make all text preformatted, it looks kinda bad

Otherwise good tutorial!
Keep going!

2 Likes