Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SCRIPTING PROPERTIES - TUTORIAL NO.1(edited)
- 1) Open roblox studio and then insert a part(edited)
- 2) Click on insert object in part and insert script
- 3) Make the whole script blank
- 4) As we are creating a game . So, Workspace comes under the game and part comes under the workspace
- FortBloxLast Monday at 11:55 AM
- 5) So, we will type
- game.Workspace.Part
- 6) '.' is basically used for directing or specifying the location of part on which we have to work
- 7) Now we will change properties of Part like Transparency and give it a value
- 8) So,the full code will be
- game.Workspace.Part.Transparency = 1
- 9) Values are given between 1 and 0..Here,1 is the highest and 0 is the lowest..You can also give it a decimal value like 0.5 or 0.43 or 0.79 which will make it translucent
- 10) CONGRATS! YOU LEARNED TO SCRIPT A BASIC CODE OF LUA!(edited)
- 11) Now play the game and see the changes and try the same code with Reflectance Property which reflects the colour of sky!
- 12)Now we will learn how to write the above property in another way!
- 13) As we know, Script comes under the Part..So,we will say Part is the parent of script and script is child of part.
- 14) So,to refer the part ..We can also type
- script.Parent
- 15) Here parent of script is Part as I already told
- 16) Now if we will try it with Transparency property..It will work :-
- script.Parent.Transparency = 0.5
- (edited)
- 17) With Reflectance :-
- script.Parent.Reflectance = 1
- 18) So,choose the code with which you are more comfortable :D and you learned another way to script the basic codes :)
- 19) Now we will use Anchored Property
- 20) Anchored is used for make the object stick to its place
- 21) In Anchored property,We don't use values like 1 or 0.5 ,We use Booleans!
- 22) Boolean is used to give a logical value to algebraic value
- 23) True and False are two types of booleans
- 24) Here True is 1 and False is 0(edited)
- 25) As 1 is 100 percent so whenever we will put Anchored = true then object will become Anchored
- 26) And 0 is 0 percent so whenever we will put Anchored = false then object will no be anchored
- 27) So the code for Anchored and opposite of it will be :-
- script.Parent.Anchored = true
- And
- script.Parent.Anchored = false
- OR
- game.Workspace.Part.Anchored = true
- And
- game.Workspace.Part.Anchored = false
- 28) One more way to Make object no longer be anchored is using 'not'(edited)
- 29) 'not' opposites the true property of Anchored
- 30) So,the following code will be :-
- script.Parent.Anchored = not script.Parent.Anchored
- 31) Now it will make Anchored Property 'false'
- 32)
- game.Workspace.Part.Anchored = not game.Workspace.Part.Anchored
- 33) The same thing will happen in this code (32nd point) :)(edited)
- 34) Now we will learn the Locked Property
- 35) Whenever,we lock any Part or Object then it becomes uneditable
- 36) You can't change any of its other property or move it or scale it or rotate it
- 37) It follows the same code like Anchored Property and the same Booleans 'true' or 'false'
- 38) So, we will type :-
- script.Parent.Locked = true
- And
- script.Parent.Locked = false
- 39) Don't type these codes at the same time because it would lock the part as
- script.Parent.Locked = false
- will be the(38the point) last line
- 40) We can also type :-
- game.Workspace.Part.Locked = true
- And
- game.Workspace.Part.Locked = false
- (edited)
- FortBloxLast Monday at 12:21 PM
- 41) Now we will move on to BrickColor Property
- 42) BrickColor Property is used to change the color of the Part
- 43) Now in this property as we have to give a new color to the Part
- 44) So,we will type
- BrickColor.new
- for giving the colour
- 45) And after that we will give it the color in brackets and inverted commas!
- 46) So,it will be
- BrickColor.new("Cyan")
- 47) And the final code will be:-
- script.Parent.BrickColor = BrickColor.new("Cyan)
- OR
- game.Workspace.Part.BrickColor = BrickColor.new("Cyan")
- 48) You can try different colours also available in Roblox studio such as ("Bright red")
- 49) Now we will learn how to change the Size of Part :)
- 50) As we know in Roblox studio and nowadays in gaming industry..Games are creating by using 3d models
- 51) So, most of the objects and Parts in Roblox studio are 3d
- 52) Hence,We will use X - axis ,y- axis and z-axis to change the size of models :)
- 53) But with that we use 'Vector' quantity/ value here
- 54) I know it maybe difficult to learn at starting but it's pretty easy and at starting I also wanted to bang the heads of coders in roblox that why they created 'Vector' xd
- 55) Now,As I already said a 3d model has X,y and z axis..So
- Vector3.new
- is used for changing the size of 3d models :)
- 56) Vector means magnitude and direction..Z axis is magnitude here and X and Y axis are Direction.
- 57) So we use 'Vector' for Size and many other Properties..It's also used in Animations :)
- 58) Now as we need to give new values to X,Y and Z axis ..So , we will type
- Vector3.new(10,20,30)
- Here,10 is X axis,20 is y axis and 30 is z axis. You can give any value to X,y and z axis :D
- 59) So,the complete code will be :-
- script.Parent.Size = Vector3.new(10,20,30)
- 60) And For 2d models,we use Vector2 ..As we don't need magnitude in 2d models..We only need X and Y axis to change the direction :)
- 61) We can also type it the other way :-
- game.Workspace.Part.Size = Vector3.new(10,20,30)
- 62) KABOOM WE LEARNT HOW TO CHANGE SIZE OF PART THROUGH SCRIPT!
- FortBloxLast Monday at 10:51 PM
- 63) Now we will learn Position Property!
- 64) Position is used to change the Position of Part on X,Y and Z axis..Z is height / magnitude here
- 65) GOOD NEWS
- Position uses same code as Size Property
- 66) So,the code will be :-
- script.Parent.Position =
- Vector3.new(100,50,-20)
- Here, negative sign is used for opposing the axis..Like in the above code, Z axis is -20 ..So it will be placed at 20 units below the origin
- 67) Same follows with X and Y axis
- 68) Another way of typing the same code :-
- game.Workspace.Part.Positon = Vector3.new(100,50,-20)
- 69) Also the part will be placed 100 units above in left direction of X axis and 50 units in upward direction of y axis
- 70) Now , we will learn how to script Velocity Property!
- 71) After writing this code.. Whenever you will step on the Part ,it will move you !!
- 72) ONE MORE GOOD NEWS
- This also follows the same code like size :)
- 73) Now X ,Y and Z axis will be used as giving speed and all after combining all the values it will move the character (us) in one direction
- 74) So,the code will be :-
- script.Parent.Velocity = Vector3.new(10,0,0)
- OR
- game.Workspace.Part.Velocity = Vector3.new(10,0,0)
- 75) It will move us in X axis by the speed of 10 units :)
- 76) Now we will learn RotVelocity
- 77) RotVelocity moves us in different directions by taking all the values of X ,Y and Z axis differently not by combining and moving it in same direction (in Velocity Property)
- 78) AGAIN A GOOD NEWS
- It follows the same code like Size Property
- 79) So we will type :-
- script.Parent.RotVelocity = Vector3.new(10,30,50)
- OR
- game.Workspace.Part.RotVelocity = Vector3.new(10,30,50)
- 80) It will first move us in direction of X-Axis by 10 units then in direction of Y-Axis by 30 units and in direction of Z-Axis by 50 units :)..So we will be revolving on the object like earth revolves around the sun!
- 81) Now,we will learn how to change some basic Properties of Part
- 82) We will learn how to Rename the Property
- 83) We will use Name Property to give a new name to the part :)
- 84) So,the code will be :-
- script.Parent.Name = "FortBlox"
- Or
- game.Workspace.Part.Name = "FortBlox"
- And it was so simple to give a new name to the part :)
- 85) Material Property also uses the same code like Name Property and you can give it a new material like "Grass" or "Wood"
- 86) FormFactor is used to change the form of the Part
- 87) The code will be :-
- script.Parent.FormFactor = "Symmetric"
- It will make the part symmetric :)
- 88)CanCollide makes the part like air..It means any object or us can pass through it.
- 89) If it will be true,then no object can pass through because it will be able to collide
- 90)If it will be false then all objects can pass through it as no object will be able to collide
- 91) So,the code will be :-
- script.Parent.CanCollide = true
- Or
- script.Parent.CanCollide = false
- 92) You can try the above codes with
- game.Workspace.Part
- also :)
- 93) You can also change other properties like Rotation which uses the same code like Size ..It is used for rotating the part :) and X axis,Y axis and Z axis are used as degrees/angles by which part gets rotated
- 94)Elasticity uses the same code like Transparency,which we did at starting ..It makes the part bouncable :)
- SCRIPTING PROPERTIES - TUTORIAL NO. 1 - COMPLETED(edited)
- SEPTEMBER 19, 2018
- FortBloxLast Wednesday at 3:10 AM
- VARIABLES AND PRINTING - TUTORIAL NO.2(edited)
- 1)Open Roblox Studio
- 2)Choose theme from baseplate or flat terrain
- 3)Make sure that your output box is open
- 4)If it's not open then:-
- Click on View tab(at top) --> Click on output(edited)
- 5)Now insert a part in workspace
- 6)Insert script in part
- 7)Now go to script and you can see
- print "Hello World" will be written
- 8) This code is used to print anything in output
- 9) For ex:- print(10)will show 10 in output
- 10) Now we will use the 'wait' command in the script
- 11)For ex:- wait(1) will let the output wait for 1 second then print the thing we wrote in script
- 12)Now we will use print and wait command together
- 13)
- print(3)
- wait(1)
- print(2)
- wait(1)
- print(1)
- wait(1)
- print(0)
- (edited)
- Here,in output countdown of 3,2,1 and 0 will be printed after 1 second as we used wait(1)
- 14) Now we will use variables
- 15) Any constant value can be given to variable!
- 16) So if we take 'x' as a variable then we can give it any value like in maths paper..When we need to find x
- 17)let's use the variables in scripting properties now.(edited)
- 18)
- yourVariable = script.Parent
- yourVariable.Transparency = 1
- So, here we took a variable by a name 'yourVariable' and assigned it value of script.Parent
- So,we don't need to type Script.Parent
- As we already gave the this value to our variable
- 19) Now let's try using variable with game.Workspace.Part
- 20)
- FortBlox = game.workspace.Part
- FortBlox.Transparency = 1
- Here, we took FortBlox as a variable and gave it the value of game.Workspace.Part
- So,we don't need to type it again!
- 21)Now let's use variables in Printing!
- 22)
- Server = 100
- print(Server)
- (edited)
- In this code,100 will be shown in output because we have given '100' value to the variable 'Server' . So,when script will be read by Roblox Studio..100 will be exchanged by 'Server' variable.(edited)
- 23)
- Server = "YAY,I AM SO HAPPY"
- print(Server)
- (edited)
- In this code, "YAY,I AM SO HAPPY" will be shown in output because we have given the above text value to the variable 'Server' . So,when the script will be read by Roblox Studio .. "YAY,I AM SO HAPPY" will be exchanged by 'Server' variable!(edited)
- 24) For now, you can also print 'true' and 'false' booleans in output.
- For example:-
- myName = true
- print(myName)
- 25)Now we will learn about a new term called Integer Value(edited)
- 26) Integer Value makes the variable available globally for the scripts in part(edited)
- 27) For example :-
- game.Workspace.IntegerValue.Value = 10
- print(game.Workspace.IntegerValue.Value)
- Now what we need to do is that
- First of all insert Integer Value(string) in workspace
- Then change its value to 50 or any value(edited)
- Then after you play the code,10 will printed in output
- As we changed the value of IntegerValue to 10 and printed the new value in next point(edited)
- 28) Everyone try the above code and if by chance not working then ask me doubt in #clear-your-doubts or DM me!(edited)
- 29) Now let's use the variable in other properties like Size(edited)
- 30)
- X = 100
- Y= 50
- Z = 130
- game.Workspace.Part.Size = Vector3.new(X,Y,Z)
- OR
- X = 100
- Y= 50
- Z = 130
- script.Parent.Size = Vector3.new(X,Y,Z)
- (edited)
- Make sure your 'Script' is under the part and here X,Y and Z are used as variables
- So when the script will be read by Roblox Studio then it will read the code as script.Parent.Size = Vector3.new(100,50,130)
- As it will put the values of variables in exchange of the variables
- VARIABLES AND PRINTING - TUTORIAL NO.2 COMPLETED(edited)
- SEPTEMBER 20, 2018
- FortBloxYesterday at 11:59 AM
- TABLES - TUTORIAL NO.3
- 1) Everyone open Roblox studio
- 2) Open baseplate theme or flat terrain theme(edited)
- 3)After that make sure your output box is open..If it's not open then go to View Tab at open and open output box
- 4) Now insert script in workspace
- 5)Make the whole script blank and now let's begin!
- 6) Well , everyone we studied variables in previous Tutorials
- 7) We gave the values to the variables like this Fortblox = 10
- 8)Now we use table to store multiple values in an ordered form.
- 9) But if we will give the value to a table like this
- mytable = 8 then it will work as variable
- 10) So,we will use { and } to give the values in between
- 11) For example :-
- mytable = {8}
- (edited)
- 12) As we store multiple values in table.. Therefore,we will type more values..for ex:-
- mytable = {8,2,4,5}
- 13) Now we will execute/use these values for some scripts like printing etc
- 14) Also "," is used to put different values like 8,2 are put differently
- 15) Now let's try this table by printing some of the values from it
- 16)
- mytable = {8,2,4,5}
- print(mytable[3])
- Now,It will show 4 in the output because in 2nd line of code,we told it to print the 3rd value of mytable which is 4! Also we put '3' in [] because they are used for telling the which value we want to show in output!
- 17) Another example :-
- mytable = {"me","you","other"}
- print(mytable[2])
- Now,it will show 'you' in output because it is the 2nd value of table as told in 2nd line of code :)(edited)
- 18) Now we will learn how to insert values in table!
- 19) We will use table.insert to insert a value in table(edited)
- 20) So the code will be :-
- mytable = {6}
- table.insert(mytable,8)
- print(mytable[1])
- print(mytable[2])
- So,in this script..We have put 6 in the table..Now in 2nd line of script,we inserted 8 after myTable which is 6..
- So,new table is mytable = {6,8} ..Now,in 3rd line of script,we told to print 1st value of mytable which is 6 and in last line of script we told to print 2nd value of mytable which is 8(new value after insertion)
- 21) Now we will learn how to remove values from table!
- 22) We will use table.remove for it.
- 23) For example:-
- mytable = {7,8,9}
- table.remove(mytable,2)
- print (mytable[2])
- (edited)
- Now we gave table 3 values which are 7,8 and 9..in 2nd line of script ,we told it to remove 2nd value from mytable which is 8..So the new 2nd value is 9 now and it will print 9 in output after 3rd line of script is executed(edited)
- 25) Now we will learn how to sort the table values in increasing order.
- 26) We will use table.sort for it!
- 27) For example :-
- yourtable = {5,9,4,1}
- table.sort(yourtable)
- print(yourtable[2])
- (edited)
- In this case ,we are sorting the table in increasing order..So after sorting the table will become like :-
- yourtable = {1,4,5,9} and after last line
- 4 will be printed as it is the 2nd value of the table after sorting
- 28) Now we will learn how to add a text between each value
- 29) We will use table.concat for this method!
- 30) For example :-
- mytable = {1,2,3,4}
- print(table.concat(mytable,"fortblox"))
- Here, in 2nd line ..fortblox will be added after each value of the mytable as we are using table.concat..and output will look like this :- "1fortblox2fortblox3fortblox4" etc.(edited)
- 31) Now we are done with almost all the tables functions!
- TABLES - TUTORIAL NO.3 COMPLETED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement