Advertisement
Vzurxy

Untitled

Sep 21st, 2018
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.52 KB | None | 0 0
  1. SCRIPTING PROPERTIES - TUTORIAL NO.1(edited)
  2. 1) Open roblox studio and then insert a part(edited)
  3. 2) Click on insert object in part and insert script
  4. 3) Make the whole script blank
  5. 4) As we are creating a game . So, Workspace comes under the game and part comes under the workspace
  6. FortBloxLast Monday at 11:55 AM
  7. 5) So, we will type
  8. game.Workspace.Part
  9. 6) '.' is basically used for directing or specifying the location of part on which we have to work
  10. 7) Now we will change properties of Part like Transparency and give it a value
  11. 8) So,the full code will be
  12. game.Workspace.Part.Transparency = 1
  13.  
  14. 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
  15. 10) CONGRATS! YOU LEARNED TO SCRIPT A BASIC CODE OF LUA!(edited)
  16. 11) Now play the game and see the changes and try the same code with Reflectance Property which reflects the colour of sky!
  17. 12)Now we will learn how to write the above property in another way!
  18. 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.
  19. 14) So,to refer the part ..We can also type
  20. script.Parent
  21.  
  22. 15) Here parent of script is Part as I already told
  23. 16) Now if we will try it with Transparency property..It will work :-
  24. script.Parent.Transparency = 0.5
  25. (edited)
  26. 17) With Reflectance :-
  27. script.Parent.Reflectance = 1
  28.  
  29. 18) So,choose the code with which you are more comfortable :D and you learned another way to script the basic codes :)
  30. 19) Now we will use Anchored Property
  31. 20) Anchored is used for make the object stick to its place
  32. 21) In Anchored property,We don't use values like 1 or 0.5 ,We use Booleans!
  33. 22) Boolean is used to give a logical value to algebraic value
  34. 23) True and False are two types of booleans
  35. 24) Here True is 1 and False is 0(edited)
  36. 25) As 1 is 100 percent so whenever we will put Anchored = true then object will become Anchored
  37. 26) And 0 is 0 percent so whenever we will put Anchored = false then object will no be anchored
  38. 27) So the code for Anchored and opposite of it will be :-
  39. script.Parent.Anchored = true
  40.  
  41.  
  42. And
  43. script.Parent.Anchored = false
  44.  
  45.  
  46. OR
  47. game.Workspace.Part.Anchored = true
  48.  
  49.  
  50. And
  51. game.Workspace.Part.Anchored = false
  52.  
  53. 28) One more way to Make object no longer be anchored is using 'not'(edited)
  54. 29) 'not' opposites the true property of Anchored
  55. 30) So,the following code will be :-
  56. script.Parent.Anchored = not script.Parent.Anchored
  57.  
  58. 31) Now it will make Anchored Property 'false'
  59. 32)
  60. game.Workspace.Part.Anchored = not game.Workspace.Part.Anchored
  61.  
  62. 33) The same thing will happen in this code (32nd point) :)(edited)
  63. 34) Now we will learn the Locked Property
  64. 35) Whenever,we lock any Part or Object then it becomes uneditable
  65. 36) You can't change any of its other property or move it or scale it or rotate it
  66. 37) It follows the same code like Anchored Property and the same Booleans 'true' or 'false'
  67. 38) So, we will type :-
  68. script.Parent.Locked = true
  69.  
  70.  
  71. And
  72.  
  73. script.Parent.Locked = false
  74.  
  75. 39) Don't type these codes at the same time because it would lock the part as
  76. script.Parent.Locked = false
  77.  
  78. will be the(38the point) last line
  79. 40) We can also type :-
  80. game.Workspace.Part.Locked = true
  81.  
  82.  
  83. And
  84. game.Workspace.Part.Locked = false
  85. (edited)
  86. FortBloxLast Monday at 12:21 PM
  87. 41) Now we will move on to BrickColor Property
  88. 42) BrickColor Property is used to change the color of the Part
  89. 43) Now in this property as we have to give a new color to the Part
  90. 44) So,we will type
  91. BrickColor.new
  92.  
  93. for giving the colour
  94. 45) And after that we will give it the color in brackets and inverted commas!
  95. 46) So,it will be
  96. BrickColor.new("Cyan")
  97.  
  98. 47) And the final code will be:-
  99. script.Parent.BrickColor = BrickColor.new("Cyan)
  100.  
  101.  
  102. OR
  103. game.Workspace.Part.BrickColor = BrickColor.new("Cyan")
  104.  
  105. 48) You can try different colours also available in Roblox studio such as ("Bright red")
  106. 49) Now we will learn how to change the Size of Part :)
  107. 50) As we know in Roblox studio and nowadays in gaming industry..Games are creating by using 3d models
  108. 51) So, most of the objects and Parts in Roblox studio are 3d
  109. 52) Hence,We will use X - axis ,y- axis and z-axis to change the size of models :)
  110. 53) But with that we use 'Vector' quantity/ value here
  111. 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
  112. 55) Now,As I already said a 3d model has X,y and z axis..So
  113. Vector3.new
  114.  
  115. is used for changing the size of 3d models :)
  116. 56) Vector means magnitude and direction..Z axis is magnitude here and X and Y axis are Direction.
  117. 57) So we use 'Vector' for Size and many other Properties..It's also used in Animations :)
  118. 58) Now as we need to give new values to X,Y and Z axis ..So , we will type
  119. Vector3.new(10,20,30)
  120.  
  121. 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
  122. 59) So,the complete code will be :-
  123. script.Parent.Size = Vector3.new(10,20,30)
  124.  
  125. 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 :)
  126. 61) We can also type it the other way :-
  127. game.Workspace.Part.Size = Vector3.new(10,20,30)
  128.  
  129. 62) KABOOM WE LEARNT HOW TO CHANGE SIZE OF PART THROUGH SCRIPT!
  130. FortBloxLast Monday at 10:51 PM
  131. 63) Now we will learn Position Property!
  132. 64) Position is used to change the Position of Part on X,Y and Z axis..Z is height / magnitude here
  133. 65) GOOD NEWS
  134. Position uses same code as Size Property
  135. 66) So,the code will be :-
  136. script.Parent.Position =
  137. Vector3.new(100,50,-20)
  138.  
  139. 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
  140. 67) Same follows with X and Y axis
  141. 68) Another way of typing the same code :-
  142. game.Workspace.Part.Positon = Vector3.new(100,50,-20)
  143.  
  144. 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
  145. 70) Now , we will learn how to script Velocity Property!
  146. 71) After writing this code.. Whenever you will step on the Part ,it will move you !!
  147. 72) ONE MORE GOOD NEWS
  148. This also follows the same code like size :)
  149. 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
  150. 74) So,the code will be :-
  151. script.Parent.Velocity = Vector3.new(10,0,0)
  152.  
  153.  
  154. OR
  155. game.Workspace.Part.Velocity = Vector3.new(10,0,0)
  156.  
  157. 75) It will move us in X axis by the speed of 10 units :)
  158. 76) Now we will learn RotVelocity
  159. 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)
  160. 78) AGAIN A GOOD NEWS
  161. It follows the same code like Size Property
  162. 79) So we will type :-
  163. script.Parent.RotVelocity = Vector3.new(10,30,50)
  164.  
  165.  
  166.  
  167. OR
  168.  
  169. game.Workspace.Part.RotVelocity = Vector3.new(10,30,50)
  170.  
  171. 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!
  172. 81) Now,we will learn how to change some basic Properties of Part
  173. 82) We will learn how to Rename the Property
  174. 83) We will use Name Property to give a new name to the part :)
  175. 84) So,the code will be :-
  176. script.Parent.Name = "FortBlox"
  177.  
  178.  
  179. Or
  180. game.Workspace.Part.Name = "FortBlox"
  181.  
  182. And it was so simple to give a new name to the part :)
  183. 85) Material Property also uses the same code like Name Property and you can give it a new material like "Grass" or "Wood"
  184. 86) FormFactor is used to change the form of the Part
  185. 87) The code will be :-
  186. script.Parent.FormFactor = "Symmetric"
  187.  
  188. It will make the part symmetric :)
  189. 88)CanCollide makes the part like air..It means any object or us can pass through it.
  190. 89) If it will be true,then no object can pass through because it will be able to collide
  191. 90)If it will be false then all objects can pass through it as no object will be able to collide
  192. 91) So,the code will be :-
  193. script.Parent.CanCollide = true
  194.  
  195.  
  196. Or
  197. script.Parent.CanCollide = false
  198.  
  199. 92) You can try the above codes with
  200. game.Workspace.Part
  201.  
  202. also :)
  203. 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
  204. 94)Elasticity uses the same code like Transparency,which we did at starting ..It makes the part bouncable :)
  205. SCRIPTING PROPERTIES - TUTORIAL NO. 1 - COMPLETED(edited)
  206. SEPTEMBER 19, 2018
  207. FortBloxLast Wednesday at 3:10 AM
  208. VARIABLES AND PRINTING - TUTORIAL NO.2(edited)
  209. 1)Open Roblox Studio
  210. 2)Choose theme from baseplate or flat terrain
  211. 3)Make sure that your output box is open
  212. 4)If it's not open then:-
  213. Click on View tab(at top) --> Click on output(edited)
  214. 5)Now insert a part in workspace
  215. 6)Insert script in part
  216. 7)Now go to script and you can see
  217. print "Hello World" will be written
  218. 8) This code is used to print anything in output
  219. 9) For ex:- print(10)will show 10 in output
  220. 10) Now we will use the 'wait' command in the script
  221. 11)For ex:- wait(1) will let the output wait for 1 second then print the thing we wrote in script
  222. 12)Now we will use print and wait command together
  223. 13)
  224. print(3)
  225. wait(1)
  226. print(2)
  227. wait(1)
  228. print(1)
  229. wait(1)
  230. print(0)
  231. (edited)
  232. Here,in output countdown of 3,2,1 and 0 will be printed after 1 second as we used wait(1)
  233. 14) Now we will use variables
  234. 15) Any constant value can be given to variable!
  235. 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
  236. 17)let's use the variables in scripting properties now.(edited)
  237. 18)
  238. yourVariable = script.Parent
  239. yourVariable.Transparency = 1
  240. So, here we took a variable by a name 'yourVariable' and assigned it value of script.Parent
  241. So,we don't need to type Script.Parent
  242. As we already gave the this value to our variable
  243. 19) Now let's try using variable with game.Workspace.Part
  244. 20)
  245. FortBlox = game.workspace.Part
  246. FortBlox.Transparency = 1
  247. Here, we took FortBlox as a variable and gave it the value of game.Workspace.Part
  248. So,we don't need to type it again!
  249. 21)Now let's use variables in Printing!
  250. 22)
  251. Server = 100
  252. print(Server)
  253. (edited)
  254. 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)
  255. 23)
  256. Server = "YAY,I AM SO HAPPY"
  257. print(Server)
  258. (edited)
  259. 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)
  260. 24) For now, you can also print 'true' and 'false' booleans in output.
  261. For example:-
  262. myName = true
  263. print(myName)
  264. 25)Now we will learn about a new term called Integer Value(edited)
  265. 26) Integer Value makes the variable available globally for the scripts in part(edited)
  266. 27) For example :-
  267. game.Workspace.IntegerValue.Value = 10
  268. print(game.Workspace.IntegerValue.Value)
  269. Now what we need to do is that
  270. First of all insert Integer Value(string) in workspace
  271. Then change its value to 50 or any value(edited)
  272. Then after you play the code,10 will printed in output
  273. As we changed the value of IntegerValue to 10 and printed the new value in next point(edited)
  274. 28) Everyone try the above code and if by chance not working then ask me doubt in #clear-your-doubts or DM me!(edited)
  275. 29) Now let's use the variable in other properties like Size(edited)
  276. 30)
  277. X = 100
  278. Y= 50
  279. Z = 130
  280.  
  281. game.Workspace.Part.Size = Vector3.new(X,Y,Z)
  282. OR
  283. X = 100
  284. Y= 50
  285. Z = 130
  286.  
  287. script.Parent.Size = Vector3.new(X,Y,Z)
  288. (edited)
  289. Make sure your 'Script' is under the part and here X,Y and Z are used as variables
  290. 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)
  291. As it will put the values of variables in exchange of the variables
  292. VARIABLES AND PRINTING - TUTORIAL NO.2 COMPLETED(edited)
  293. SEPTEMBER 20, 2018
  294. FortBloxYesterday at 11:59 AM
  295. TABLES - TUTORIAL NO.3
  296. 1) Everyone open Roblox studio
  297. 2) Open baseplate theme or flat terrain theme(edited)
  298. 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
  299. 4) Now insert script in workspace
  300. 5)Make the whole script blank and now let's begin!
  301. 6) Well , everyone we studied variables in previous Tutorials
  302. 7) We gave the values to the variables like this Fortblox = 10
  303. 8)Now we use table to store multiple values in an ordered form.
  304. 9) But if we will give the value to a table like this
  305. mytable = 8 then it will work as variable
  306. 10) So,we will use { and } to give the values in between
  307. 11) For example :-
  308. mytable = {8}
  309. (edited)
  310. 12) As we store multiple values in table.. Therefore,we will type more values..for ex:-
  311. mytable = {8,2,4,5}
  312. 13) Now we will execute/use these values for some scripts like printing etc
  313. 14) Also "," is used to put different values like 8,2 are put differently
  314. 15) Now let's try this table by printing some of the values from it
  315. 16)
  316. mytable = {8,2,4,5}
  317. print(mytable[3])
  318.  
  319.  
  320. 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!
  321. 17) Another example :-
  322. mytable = {"me","you","other"}
  323. print(mytable[2])
  324.  
  325.  
  326. Now,it will show 'you' in output because it is the 2nd value of table as told in 2nd line of code :)(edited)
  327. 18) Now we will learn how to insert values in table!
  328. 19) We will use table.insert to insert a value in table(edited)
  329. 20) So the code will be :-
  330. mytable = {6}
  331. table.insert(mytable,8)
  332. print(mytable[1])
  333. print(mytable[2])
  334. 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..
  335. 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)
  336. 21) Now we will learn how to remove values from table!
  337. 22) We will use table.remove for it.
  338. 23) For example:-
  339. mytable = {7,8,9}
  340. table.remove(mytable,2)
  341. print (mytable[2])
  342. (edited)
  343. 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)
  344. 25) Now we will learn how to sort the table values in increasing order.
  345. 26) We will use table.sort for it!
  346. 27) For example :-
  347. yourtable = {5,9,4,1}
  348. table.sort(yourtable)
  349. print(yourtable[2])
  350. (edited)
  351. In this case ,we are sorting the table in increasing order..So after sorting the table will become like :-
  352. yourtable = {1,4,5,9} and after last line
  353. 4 will be printed as it is the 2nd value of the table after sorting
  354. 28) Now we will learn how to add a text between each value
  355. 29) We will use table.concat for this method!
  356. 30) For example :-
  357. mytable = {1,2,3,4}
  358. print(table.concat(mytable,"fortblox"))
  359. 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)
  360. 31) Now we are done with almost all the tables functions!
  361. TABLES - TUTORIAL NO.3 COMPLETED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement