Begineer guide to scripting

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

properties and explorer

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.

image

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.

image

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

image

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

image

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!

:heart:

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

22 Likes

Thanks for this; now I understand how to create functions!

I made a edit about functions check it out!

1 Like

I cant wait till Chapter 2. I really enjoyed your tutorial. Functions part is just a 5 out of 5. I understand them more.

Anyone thinking about what part 2 is going to be about, part 2 will be about instance.new, function parameters, and variables and there might be a part 3

Thank you for the support! @kry1068

Is the function there meant to not have an end

Wouldn’t it error

That was a accident, im sorry i forgot a end

This is a nice little introduction and step by step, however I have some critique for your code;

First, the end is missing from your function - please correct.

Formatting
In order to make things easier for yourself and other developers, it is good practice to format your code correctly.
This means using the specific names of properties, functions and values, as well as tabbing your functions and if statement code so it is more readable.

Remember, computers are dumb, and unless you’re working specifically with a language that doesn’t require correct capitalisation (such as SQL) , you should definitely always use it as computers will typically not interpret what you mean.

part.material = "grass" -- this isn't great
part.Material = "Grass" -- that uses the correct format of the name of the property as well as its Enumerated value.

part = instance.new("part") -- incorrect function name and enum value name
local part = Instance.new("Part") -- correct formatting. 

--Functions:
--BAD
function doThing(a)
print("this")
if a then
print(a,"is a thing")
end
end

--GOOD
function PrintValue(value)
	print("this")
	if value then
		print(value,"is a thing") -- this is much easier to follow. =)
	end
end

I’ll share this page with my friend once you’ve fixed your examples.
Thanks for putting in the time for this little tutorial, it will help many. =)

How are you going to make a tutorial about instance.new, and function parameters when you haven’t even made the best usage of it here in this tutorial? Using practices here that aren’t even recomended like instance.new("BasePart", game.workspace).

For 1, you’re using game.workspace. Why not just workspace? How long have you been scripting? I feel like you watched 2 youtube videos and became an expert.

I know i have used for bad practises

I will tell that using that practise is bad in my next tutorial. By the way, look at my profile im a begineer so im not saying im an expert

You should not be using game.workspace in the instance.new as that is bad

Just so you are aware, there is a little Pencil icon at the bottom of your post that allows you to edit it. :slight_smile:
image

I know but i accidentally submitted it and doesnt let me edit that part out so :confused:

Exactly, and a beginner is making a tutorial. Fam, there’s so many developers on the platform that’s been here for years. Yeah, it’s kind of sad some of them don’t make beginner tutorials. But when a beginner make a tutorial and they haven’t grasped the foundation of programming, you’re just spreading bad practices.

I’m not trying to put you down, I just think it’d be more beneficial to everyone if you had a bit more experience before making these tutorials. They’re just bloating the resources section which is like the only gem left on this forum.

I will tell that is a bad practise, as I said, and im not a begineer begineer im like kind of good

I will tell bad pracitse next tutorial

I was going to right that and change it but it didnt let me because i accidentally submitted as i said above…

I know that every begineer makes mistakes plus this was my first ever post