Welcome to begineers guide to scripting
In this guide, I will be teaching you all the necessary things you should be knowing as a begineer to scripting. This is very basic, and will probably only help begineers.
First : Explorer and properties tab
Do you see the tab on the top that says workspace. If you do, that is what you call the explorer tab. The one on the bottom which says data, behaviour and other things is what you call the properties tab.
Explorer
The Explorer tab is a tab used for finding all instances used in your game. You might be thinking what are instances? Well, I won’t go into depth about what that is, but just think about it as scripts and parts.
Properties
Properties tab is a tab used to change all the properties of something. Think about this, as an example. You inserted a part into roblox studio. It is grey right. You are probably wanting to change the colour of the part to red. Then you would go to the properties tab and scroll down to find a property that says color, then you select it to red. There you go! Your part is now red.
Second : Printing
What is printing?
Printing is a very useful, even thought many people think it is very useless. Printing helps you debug or find errors in your script. There are many ways to use printing, But one common way is to debug your script.
How to print
Now head over to your explorer tab,and hover over Serverscriptservice and you should see a plus symbol.
Then click on that plus, and find the word script, after you have found it click on it. Now you have inserted a script. Anyone thinking what is servicescriptservice. It just basically is a place for your scripts to be stored.
Now open that script up.
In the script you should see something that says
print("hello world")
When you see that, highlight it, and press delete on your keyboard. That should of removed print("hello world")
and made it blank.
Now lets print something except hello world.
So now in your script type in
print("good")
Now open the output tab.
So open the top of your screen, do you see something that says view? Press on it.
Now you see those little icons, find this one.
and click on it.
This opened the output tab.
Now, on the top-right of your screen, you should see a tiny icon, that looks like this
Now press on it.
Wait a few seconds. Now look in the output! It says good right?
Now look on the top-right again. Do you see this icon
Press on it.
This made you stop running the game.
Now go back to your script.
A bit more information about printing
When you print something you type in
print()
In those brackets, you type in whatever you want to say
like this
print("hello")
When typing what you want to print, you must put it in speech marks.
Functions
Let’s say you want to create 50 parts, using code
local part = Instance.new("Part",game.workspace)
part.Material = "grass"
part.Color = color3.fromRGB(255,255,255)
Say that is the part you want.
And you need to create 50 of them. You will probably be thinking that you have to keep copy and pasting the same code 50 times.
No, you don’t have to do that, you can make something called functions and you can do it in a blink of an eye.
So let me tell you what functions are:
What are functions
Functions are predefined code, that can be used as many times as you want.
How to create a function
Now in your script, right this code in
function createpart()
local part = Instance.new("Part")
part.Material = "grass"
part.Transparency = 0.5
part.Parent = game.workspace
end
createpart()
createpart()
createpart()
createpart()
createpart()
createpart()
createpart()
createpart()
createpart()
createpart()
createpart()
createpart()
This made lots of parts. That is what a function is in a essence.
When you make a function. You kind of have to give it a name. The name doesn’t have to be related to what your making, the name of the function can literally be anything you want, just remember to have a () at the end of the name.
So, lets say your making a part function like I did. You have to instance the part or make a predefined part in workspace. But I won’t cover that in this one. Then you can make the part change it’s properties. But remember if you instanced it, remember to change the parent to game.workspace.
Then you after you made the function and you run the game nothing will appear because you didn’t call the function. To call a function, you have to type in the function’s name like I did. The function’s name is createpart().
Now if i run it, I have a part, with the properties.
That is going to be all for today’s basic one, I am still a begineer scripter, so please correct me on any errors I made in my script.
I will make a chapter 2 soon. So keep searching for that. But that is all for today!
Edit: I made you guys follow a bad practise in coding so let me tell you that the error is in when i wrote
local part = Instance.new("part",game.workspace)
part.Material = "grass"
part.Color = color3.fromRGB(255,255,255)
when I wrote local part = Instance.new(“part”,game.workspace), it follows a bad practise many people shouldn’t be using. You should write the location of where the part is in the instancing line itself, but in another line so it should be written like this
local part = Instance.new("Part")
part.Parent = workspace
This is a better practise and say that any future developers follow it.
I’m just saying never have a second argument in your instancing.
You shouldn’t be using the 2nd argument of Instance.new()
.
Go look at that post.
Link from @jaipack17