Advertisement
mariyandog999

Portfolio

Jun 25th, 2021
635
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 52.00 KB | None | 0 0
  1. types of varibles on roblox
  2. varibles --a way to shorten scripts/store information -- example local.
  3. (so you dont have to write the same thing over and over you can use local)
  4.  varibles give access to properties
  5. 1 "" (string)
  6. 2 1331 (number)
  7. 3 true/false (boolean)
  8. 4 game.Workspace. (object reference
  9.  
  10. print = ("dogs are cool")
  11.  
  12.  
  13.  Instance.new() -- allows you to insert things into your game from a script
  14.   Ex:Instance.new("Brick")an object goes in the()
  15.  how to do it Instance.new("brick",)
  16.   Instance.new(brick,) tells to put the brick in the Workspace
  17.   local myBrick = Instance.new("brick")
  18.   myBrick.Trapsparency = 0.5
  19.   myBrick.Anchored = true
  20.   myBrick.Position = Vector3.new (5,5,5) -- this is how to position
  21.  
  22.   myBrick.Parent = game.Worspace -- always have this after the properties
  23.  
  24.  
  25. Functions generatePart (name) is = to PartNumberOne
  26.  
  27.    Instance.new(brick,) tells to put the brick in the Workspace
  28.    local myBrick = Instance.new("brick")
  29.    myBrick.Trapsparency = 0.5
  30.    myBrick.Anchored = true
  31.    myBrick.Position = Vector3.new (5,5,5)  
  32.  end -- any code needs to go between the function and the end  
  33.  
  34.   generatePart()-- this let you save time instead of copying 50 lines
  35.   generatePart()-- also makes your code neatter
  36.   generatePart()-- functions make your save time and make your code neater
  37.   generatePart()
  38.   generatePart()
  39.  
  40.  
  41.  
  42. Function Parameter/Argruments
  43.  
  44.   generatePart("PartNumberOne")goes to name
  45.   generatePart() -- this is the Agrument and the function is the Parameter
  46.   generatePart()
  47.   generatePart()
  48.   generatePart()
  49. -- you need to name the part add a name in the ()
  50.   ex:generatePart(jijij) -- jijij is the name of the brick
  51.   Arguements pass data to the function
  52.  
  53. function printText(stringToPrint)
  54.       print(stringToPrint
  55.   end
  56. PrintText("hello dogs")
  57. PrintText("robux")
  58.  
  59.  
  60.  
  61. built in functions
  62. 5 most popular
  63.  
  64. 1 Destroy()
  65. 2 Clone()
  66. 3 ClearAllChildren()
  67. 4 wait()
  68. 5 print()
  69.  
  70. when you do : its calling a function
  71.  
  72. game.Workspace.MyBrick:Destroy() -- when you run the game this script destroies the part
  73.  
  74.  local myClone = game.Workspace.Brick:Clone()
  75.  myClone.Parent = game.Workspace
  76.   wait(5)
  77.  game.Workspace.MyBrick:ClearAllChildren()
  78.  -- this script will clone the part then it will wait 5 seconds then will ClearAllChildren
  79.  
  80.  print("HELLO")
  81.  --  print is a why to see where your script broke.
  82. end
  83.  
  84.  
  85.  
  86. Events -- are what help things happen/trigger things
  87. Ex:step on a banana then you trip -- triggered that
  88. Example of a touched event script
  89.  
  90. script.Parent.Touched:Connect(function(hit)
  91.    if game.Players:GetPlayersFromCharacter(hit.Parent) then
  92.       hit.Parent.Humanoid.Sit = true
  93.     end
  94.  
  95.  end)
  96.  -- this script needs to go in the object like the banana
  97.  -- this is setting a event that is telling when you slip on the banana you fall
  98.  -- :Connect is telling when the event happens/triggers
  99.  -- Touched is the event
  100.  function hello()
  101.    print("hello")
  102.  end
  103.  
  104.   game.Workspace.Banana.Touched:Connect(function()      
  105.                    print ("Hello")
  106.        end )
  107.  -- this will make the output say hello  when you touched the banana
  108.  -- you need the tie the event to the function like I just did
  109.  -- you need to put the code in the function for it to work
  110.  
  111. game.Workspace.Banana.Touched:Connect(function(hit)      
  112.                    print (hit.Name)
  113.       end)
  114.  --this will print all the body parts touching the banana
  115.  -- this is just one event
  116.  -- you could think its a varible
  117.  
  118.  game.Workspace.Banana.Touched:Connect(function(hit)
  119.      if game.PLayers:GetPlayerFromCharacter(hit.Parent) then  
  120.     hit.parent.Humanoid.Sit = true
  121.   end)
  122. -- this script will make the player sit
  123. -- GetPlayerFromChracter is checking if it a actual player
  124.  
  125.  
  126.  
  127.  
  128.  
  129. IF STATMENTS
  130.  
  131. how to do if statments
  132.  
  133. if 2+2 = 4 then
  134.     print ("Correct ")
  135. end -- if this is is correct the output will print correct
  136.  
  137.  if false then
  138.     print ("Correct ")
  139. end
  140.  
  141.  if true then
  142.     print ("Correct ")
  143. end
  144.  
  145.  
  146.     if game.Lighting.TimeOfDay == "12:00:00 then
  147.    print ("Correct ")
  148. end -- this is a way to check  
  149.  
  150.  
  151.  
  152.   while wait (1) do
  153.    if game.Lighting.TimeOfDay == "12:00:00 then
  154.     print ("Correct ")
  155.    end  
  156. end --  this is a while loop it will always check
  157.    
  158.  
  159.       if game.Lighting.TimeOfDay == "12:00:00 then
  160.    print ("Correct ")
  161.  else
  162.      print("Incorrect")
  163. end -- if its 12 it will say correct, if it is not it will say incorret.
  164.  
  165.  
  166.  
  167.  
  168. Elseif and embedded if statments
  169.  
  170. local myNumber = 3
  171.  
  172. if myNumber % 2 == 0 then print
  173.   print ("it's even")
  174. elseif myNumber 3 == 0 then
  175.   print ("It's a multiple of 3!")
  176. end
  177.   elseif myNumber % 5 == 0 then print
  178.   print ("It's a multiple of 5!")
  179. else
  180.    print ("they did all not run")
  181. end
  182.  
  183. relational/conditional Operators
  184.  
  185. all elseif symbols
  186.  
  187. 1 > Greater than
  188. 2 < Less than
  189. 3 >= Greater than or equal to
  190. 4 ~= Not equal to
  191. 5 == equal to
  192.  
  193.  
  194.  
  195. Values -BoolValues, StringValues, IntValues, etc.
  196.  
  197.  -- Values hold data you can add a Value by click the + with a circle
  198. -- always make sure you name your values
  199. -- place most values in SeverStorage
  200. script 1 game.SeverStorage.BoolValue.Value)
  201. script 2 print(game.SeverStorage.Boolvalue.Value)
  202.      wait(5)
  203.      game.SeverStorage.BoolValue == false  
  204. -- StringValues only take a String
  205. -- CFram is a position Value -- to set a Cframe you need to do it in your script
  206.   like this game.SeverStorage.Cfram.Value = Cfram.new (3,3,3)
  207.  
  208.  
  209.  
  210. While Loops
  211.  
  212. -- any code inside a while will repeat and repeat its self forever
  213.  
  214. ex of a while loop
  215.  while true do
  216.   print ("this is cool ")
  217.    wait(1)
  218.  
  219.  
  220.  
  221.  
  222. Repeating
  223.  
  224. repeat
  225.   print("Not enough parts in the game")
  226.   wait()
  227. Until  #game.Workspace.Part:GetChildren () > 1
  228.  
  229.   print("Enough parts are here ")
  230. end
  231.  
  232. repeat
  233.  print("not enough players in the game")
  234.   wait(4)
  235. until
  236.  #game.Players:GetPlayers() <= 2
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244. Tables (table.remove / table.insert)
  245.  
  246.  
  247. local MyVAr = game.Workspace.Baseplate
  248.  
  249. local MyTab;e = {11,2,3,4,2,32,1,5}
  250.  
  251. MyTable [1]-- this is game.Workspace.Baseplate
  252. -- tables can access data like that
  253. for i,   v in pairs () do
  254.  
  255. end
  256.  
  257. local MyVAr = game.Workspace.Baseplate
  258.  
  259. local myTable = {game.Workspace.baseplate,"tottenham",50,false}
  260.  
  261.  
  262. local playersInRound = {game.Player.Mariyan,Game.Player.John,Game.Player.Dog}
  263.  
  264. table.remove(playersInRound,1)-- TO REMOVE A PLAYER THIS IS VERY IMPORTANT
  265.  
  266. en
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.   local playerInRound - {"alvin"bob""alan"}
  277. print(playersInRound[2])
  278. Wait(2)
  279. table.insert(playersInRound,2,"jon")
  280. print(playerInRound[2])
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289. In pairs Loops
  290.  
  291.  
  292.  
  293. local myTab = {"hello,3,4,false"}
  294.  
  295. for i, v in pairs (MyTab) do
  296.   print (i)
  297.   print (v)
  298. end
  299. -- it will print hello 4 times because 4 items are in the table
  300. -- the reapeating is based on the items in the table
  301. -- the i is the index value  -- the 2 item in the table
  302. -- the v stands for value, the value of the index -- the third 3 item in the table
  303. -- you need at least 3 items in the table
  304. local myTab = {1,2,3,4,5,6,7,8,9,10}
  305. print (myTab[2])
  306.  
  307. wait ()
  308.  
  309. for i, v in pairs (MyTab) do
  310.  v = v * 2
  311.  
  312. end
  313.  
  314.  
  315. local myTab - {1,2,3,4,56,7,8,9,10}
  316.  
  317.  print (myTab[2])
  318.  
  319. wait (2)
  320.  
  321. for i, v in pairs (myTab)
  322.   myTab = v*2
  323. end
  324.  
  325.  
  326.  print (myTab) [2] )
  327.  
  328. end
  329.  
  330. -- myTab = v*2 will double the 2 in the table thus the output saying 4 cuz 2*2= 4
  331.  
  332. you can add any items to a table such as
  333.  
  334. local myTab = {game.Workspace.Baseplate,game.Workspace.Terrain
  335.  
  336. -- you can do :GetChildren() so it will take everything in the file
  337. local buildingsTable = game.Workspace.Buildings.GetChildren()
  338.  
  339. local buildingsTable = {game.Workspace.Buildings.building}
  340.  
  341. for i, v in pairs (buildingTable) do
  342. v:Destory() to delete
  343. wait (0.1)
  344. end
  345. -- it will take everything then loop through it
  346. -- v.Material = "Neon"
  347. for i, v in pairs (game.Players:GetPlayers ()) do
  348. v.Character.HumanoidRootPart.Position = Vector3.new( 12323.123.12.3)
  349. in the () you could add a position just like i did where that position is the players will spawn
  350.  
  351.  
  352. Services and Getservice()
  353. -- is an object and contains built in properties,functions,events
  354. --Services are basically like Workspace serverscript and chat
  355. -- only roblox makes services
  356. Types of services
  357. Main
  358. We can see their properies like 1 workspacce 2 CoreGui 3 Starter playe
  359.  
  360. Other services
  361. -- used for handy events and lighting is one of them they are like extra details
  362.  
  363. Example game:Getservice("Workspace")
  364.  
  365. this will give you information about thing
  366. game.User(Inputservice):GetConnectedGamepads()
  367.  
  368. you could put any service name in the Inputservice) of the code
  369.  
  370. game:("Lighting").TimeOfDay = "23:00:00"
  371.  
  372. how to fill a cup
  373. ["Decaf"] = function(Tool)
  374.         if Tool.Name == "Cup" then
  375.             FillCup(Tool,BrickColor.new("Pine Cone"),0,"Decaf")
  376.         end
  377. types of varibles on roblox
  378. varibles --a way to shorten scripts/store information -- example local.
  379. (so you dont have to write the same thing over and over you can use local)
  380. varibles give access to properties
  381. 1 "" (string)
  382. 2 1331 (number)
  383. 3 true/false (boolean)
  384. 4 game.Workspace. (object reference
  385.  
  386. print = ("dogs are cool")
  387.  
  388.  
  389. Instance.new() -- allows you to insert things into your game from a script
  390.  Ex:Instance.new("Brick")an object goes in the()
  391. how to do it Instance.new("brick",)
  392.  Instance.new(brick,) tells to put the brick in the Workspace
  393.  local myBrick = Instance.new("brick")
  394.  myBrick.Trapsparency = 0.5
  395.  myBrick.Anchored = true
  396.  myBrick.Position = Vector3.new (5,5,5) -- this is how to position
  397.  
  398.  myBrick.Parent = game.Worspace -- always have this after the properties
  399.  
  400.  
  401. Functions generatePart (name) is = to PartNumberOne
  402.  
  403.   Instance.new(brick,) tells to put the brick in the Workspace
  404.   local myBrick = Instance.new("brick")
  405.   myBrick.Trapsparency = 0.5
  406.   myBrick.Anchored = true
  407.    myBrick.Position = Vector3.new (5,5,5)  
  408. end -- any code needs to go between the function and the end  
  409.  
  410.  generatePart()-- this let you save time instead of copying 50 lines
  411.  generatePart()-- also makes your code neatter
  412.  generatePart()-- functions make your save time and make your code neater
  413.  generatePart()
  414.  generatePart()
  415.  
  416.  
  417.  
  418. Function Parameter/Argruments
  419.  
  420.  generatePart("PartNumberOne")goes to name
  421.  generatePart() -- this is the Agrument and the function is the Parameter
  422.  generatePart()
  423.  generatePart()
  424.  generatePart()
  425. -- you need to name the part add a name in the ()
  426.  ex:generatePart(jijij) -- jijij is the name of the brick
  427.  Arguements pass data to the function
  428.  
  429. function printText(stringToPrint)
  430.      print(stringToPrint
  431.  end
  432. PrintText("hello dogs")
  433. PrintText("robux")
  434.  
  435.  
  436.  
  437. built in functions
  438. 5 most popular
  439.  
  440. 1 Destroy()
  441. 2 Clone()
  442. 3 ClearAllChildren()
  443. 4 wait()
  444. 5 print()
  445.  
  446. when you do : its calling a function
  447.  
  448. game.Workspace.MyBrick:Destroy() -- when you run the game this script destroies the part
  449.  
  450. local myClone = game.Workspace.Brick:Clone()
  451. myClone.Parent = game.Workspace
  452.  wait(5)
  453. game.Workspace.MyBrick:ClearAllChildren()
  454. -- this script will clone the part then it will wait 5 seconds then will ClearAllChildren
  455.  
  456. print("HELLO")
  457. --  print is a why to see where your script broke.
  458. end
  459.  
  460.  
  461.  
  462. Events -- are what help things happen/trigger things
  463. Ex:step on a banana then you trip -- triggered that
  464. Example of a touched event script
  465.  
  466. script.Parent.Touched:Connect(function(hit)
  467.   if game.Players:GetPlayersFromCharacter(hit.Parent) then
  468.      hit.Parent.Humanoid.Sit = true
  469.    end
  470.  
  471. end)
  472. -- this script needs to go in the object like the banana
  473. -- this is setting a event that is telling when you slip on the banana you fall
  474. -- :Connect is telling when the event happens/triggers
  475. -- Touched is the event
  476. function hello()
  477.   print("hello")
  478. end
  479.  
  480.  game.Workspace.Banana.Touched:Connect(function()      
  481.                   print ("Hello")
  482.       end )
  483. -- this will make the output say hello  when you touched the banana
  484. -- you need the tie the event to the function like I just did
  485. -- you need to put the code in the function for it to work
  486.  
  487. game.Workspace.Banana.Touched:Connect(function(hit)      
  488.                   print (hit.Name)
  489.      end)
  490. --this will print all the body parts touching the banana
  491. -- this is just one event
  492. -- you could think its a varible
  493.  
  494. game.Workspace.Banana.Touched:Connect(function(hit)
  495.     if game.PLayers:GetPlayerFromCharacter(hit.Parent) then  
  496.    hit.parent.Humanoid.Sit = true
  497.  end)
  498. -- this script will make the player sit
  499. -- GetPlayerFromChracter is checking if it a actual player
  500.  
  501.  
  502.  
  503.  
  504.  
  505. IF STATMENTS
  506.  
  507. how to do if statments
  508.  
  509. if 2+2 = 4 then
  510.    print ("Correct ")
  511. end -- if this is is correct the output will print correct
  512.  
  513. if false then
  514.    print ("Correct ")
  515. end
  516.  
  517. if true then
  518.    print ("Correct ")
  519. end
  520.  
  521.  
  522.    if game.Lighting.TimeOfDay == "12:00:00 then
  523.    print ("Correct ")
  524. end -- this is a way to check  
  525.  
  526.  
  527.  
  528.   while wait (1) do
  529.    if game.Lighting.TimeOfDay == "12:00:00 then
  530.    print ("Correct ")
  531.   end  
  532. end --  this is a while loop it will always check
  533.  
  534.  
  535.      if game.Lighting.TimeOfDay == "12:00:00 then
  536.    print ("Correct ")
  537.  else
  538.      print("Incorrect")
  539. end -- if its 12 it will say correct, if it is not it will say incorret.
  540.  
  541.  
  542.  
  543.  
  544. Elseif and embedded if statments
  545.  
  546. local myNumber = 3
  547.  
  548. if myNumber % 2 == 0 then print
  549.   print ("it's even")
  550. elseif myNumber 3 == 0 then
  551.   print ("It's a multiple of 3!")
  552. end
  553.   elseif myNumber % 5 == 0 then print
  554.   print ("It's a multiple of 5!")
  555. else
  556.    print ("they did all not run")
  557. end
  558.  
  559. relational/conditional Operators
  560.  
  561. all elseif symbols
  562.  
  563. 1 > Greater than
  564. 2 < Less than
  565. 3 >= Greater than or equal to
  566. 4 ~= Not equal to
  567. 5 == equal to
  568.  
  569.  
  570.  
  571. Values -BoolValues, StringValues, IntValues, etc.
  572.  
  573.  -- Values hold data you can add a Value by click the + with a circle
  574. -- always make sure you name your values
  575. -- place most values in SeverStorage
  576. script 1 game.SeverStorage.BoolValue.Value)
  577. script 2 print(game.SeverStorage.Boolvalue.Value)
  578.      wait(5)
  579.      game.SeverStorage.BoolValue == false  
  580. -- StringValues only take a String
  581. -- CFram is a position Value -- to set a Cframe you need to do it in your script
  582.   like this game.SeverStorage.Cfram.Value = Cfram.new (3,3,3)
  583.  
  584.  
  585.  
  586. While Loops
  587.  
  588. -- any code inside a while will repeat and repeat its self forever
  589.  
  590. ex of a while loop
  591.  while true do
  592.   print ("this is cool ")
  593.    wait(1)
  594.  
  595.  
  596.  
  597.  
  598. Repeating
  599.  
  600. repeat
  601.   print("Not enough parts in the game")
  602.   wait()
  603. Until  #game.Workspace.Part:GetChildren () > 1
  604.  
  605.   print("Enough parts are here ")
  606. end
  607.  
  608. repeat
  609.  print("not enough players in the game")
  610.   wait(4)
  611. until
  612.  #game.Players:GetPlayers() <= 2
  613.  
  614.  
  615.  
  616.  
  617.  
  618.  
  619.  
  620. Tables (table.remove / table.insert)
  621.  
  622.  
  623. local MyVAr = game.Workspace.Baseplate
  624.  
  625. local MyTab;e = {11,2,3,4,2,32,1,5}
  626.  
  627. MyTable [1]-- this is game.Workspace.Baseplate
  628. -- tables can access data like that
  629. for i,   v in pairs () do
  630.  
  631. end
  632.  
  633. local MyVAr = game.Workspace.Baseplate
  634.  
  635. local myTable = {game.Workspace.baseplate,"tottenham",50,false}
  636.  
  637.  
  638. local playersInRound = {game.Player.Mariyan,Game.Player.John,Game.Player.Dog}
  639.  
  640. table.remove(playersInRound,1)-- TO REMOVE A PLAYER THIS IS VERY IMPORTANT
  641.  
  642. en
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.   local playerInRound - {"alvin"bob""alan"}
  653. print(playersInRound[2])
  654. Wait(2)
  655. table.insert(playersInRound,2,"jon")
  656. print(playerInRound[2])
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665. In pairs Loops
  666.  
  667.  
  668.  
  669. local myTab = {"hello,3,4,false"}
  670.  
  671. for i, v in pairs (MyTab) do
  672.    print (i)
  673.    print (v)
  674. end
  675. -- it will print hello 4 times because 4 items are in the table
  676. -- the reapeating is based on the items in the table
  677. -- the i is the index value  -- the 2 item in the table
  678. -- the v stands for value, the value of the index -- the third 3 item in the table
  679. -- you need at least 3 items in the table
  680. local myTab = {1,2,3,4,5,6,7,8,9,10}
  681. print (myTab[2])
  682.  
  683. wait ()
  684.  
  685. for i, v in pairs (MyTab) do
  686.   v = v * 2
  687.  
  688. end
  689.  
  690.  
  691.  local myTab - {1,2,3,4,56,7,8,9,10}
  692.  
  693.   print (myTab[2])
  694.  
  695. wait (2)
  696.  
  697. for i, v in pairs (myTab)
  698.    myTab = v*2
  699. end
  700.  
  701.  
  702.   print (myTab) [2] )
  703.  
  704. end
  705.  
  706. -- myTab = v*2 will double the 2 in the table thus the output saying 4 cuz 2*2= 4
  707.  
  708. you can add any items to a table such as
  709.  
  710. local myTab = {game.Workspace.Baseplate,game.Workspace.Terrain
  711.  
  712. -- you can do :GetChildren() so it will take everything in the file
  713. local buildingsTable = game.Workspace.Buildings.GetChildren()
  714.  
  715. local buildingsTable = {game.Workspace.Buildings.building}
  716.  
  717. for i, v in pairs (buildingTable) do
  718. v:Destory() to delete
  719. wait (0.1)
  720. end
  721. -- it will take everything then loop through it
  722. -- v.Material = "Neon"
  723. for i, v in pairs (game.Players:GetPlayers ()) do
  724. v.Character.HumanoidRootPart.Position = Vector3.new( 12323.123.12.3)
  725. in the () you could add a position just like i did where that position is the players will spawn
  726.  
  727.  
  728. Services and Getservice()
  729. -- is an object and contains built in properties,functions,events
  730. --Services are basically like Workspace serverscript and chat
  731. -- only roblox makes services
  732. Types of services
  733. Main
  734.  We can see their properies like 1 workspacce 2 CoreGui 3 Starter playe
  735.  
  736. Other services
  737. -- used for handy events and lighting is one of them they are like extra details
  738.  
  739. Example game:Getservice("Workspace")
  740.  
  741. this will give you information about thing
  742. game.User(Inputservice):GetConnectedGamepads()
  743.  
  744. you could put any service name in the Inputservice) of the code
  745.  
  746. game:("Lighting").TimeOfDay = "23:00:00"
  747.  
  748. how to fill a cup
  749. ["Decaf"] = function(Tool)
  750.         if Tool.Name == "Cup" then
  751.             FillCup(Tool,BrickColor.new("Pine Cone"),0,"Decaf")
  752.         end
  753.  
  754. roblox gui series
  755. Roblox GUI Scripting Tutorial #1 - Introduction to GUIs
  756. all gui are only for client and made for them
  757. insert gui in the StarterGui
  758. you need to have a screen gui as the parent of all guis
  759.  
  760. Roblox GUI Scripting Tutorial #2 - TextButton
  761. local MainGui = script.Parent
  762. -- there is many events you could use
  763. local Text = MainGui.TextButton
  764.  
  765. Text.MouseButton1Up:Connect(function()
  766. print("Clicked")
  767.  
  768. end)
  769.  
  770. Roblox GUI Scripting Tutorial #3 - TextBox
  771. like a search bar
  772.  
  773. Roblox GUI Scripting Tutorial #4 - ImageLabels & ImageButtons
  774. You could press imageButtons but not ImageLabels
  775. local ScreenGui = script.Parent
  776. local ShopFrame = ScreenGui.ShopFrame -- Frame of the Image
  777. local OpenShop = ScreenGui.OpenShop -- Image
  778. OpenShop.MouseButton1Up:Connect(function()
  779.  
  780. ShopFrame.Visible = not ShopFrame.Visible
  781. end)
  782.  
  783. Roblox GUI Scripting Tutorial #5 - Tweening GUI
  784. local Inventory = script.Parent.Inventory
  785. local OpenInventory = script.Parent.OpenInventory
  786.  
  787. OpenInventory.MouseButton1Up:Connect(function()
  788.     Inventory:TweenPosition(
  789.         UDim2.new(0.275, 0.100, 0),-- end position
  790.         "Out",-- easing Direction
  791.         "Quad",-- easing style
  792.         1,-- lengt how long it will take to open the Inventory
  793.         false, -- override other tweens
  794.         nil
  795.     )
  796. end)
  797. OpenInventory.MouseButton1Up:Connect(function()
  798.     Inventory.Position = UDim2.new(-2.75, 0.100, 0)
  799. end)
  800. Roblox GUI Scripting Tutorial #6 - UI Constraints & Layouts
  801. organize inventoirs with them
  802.  
  803. Roblox GUI Scripting Tutorial #8 - Billboard GUIs
  804. put  a billboard gui  a character
  805. insert a textLabel in the billboard gui
  806. adornee it to the head
  807. Roblox GUI Scripting Tutorial #9 - Surface GUIs
  808. basically billboard guis just 1 face
  809.  DevKing scripting
  810.  
  811. Beginner's Roblox Scripting Tutorial #3 - Variables
  812.  
  813. local Myname
  814. local HotDog = 4
  815.  
  816. The variable is the word after the local
  817. like HotDog
  818.  
  819. Beginner's Roblox Scripting Tutorial #4 - Arithmetic + Object-Oriented Programming
  820.  
  821. print (10 + 10)
  822. --output will say 20
  823. local Baseplate = game.Workspace.Baseplate
  824. Baseplate.material ="Wood"
  825. if there is a check you need to say = true or false
  826. -- way to adjust properties
  827.  
  828. Beginner's Roblox Scripting Tutorial #5 - Functions
  829. local function BestFunction()
  830.  
  831. local best number = 10
  832. local worst number = 15
  833.  
  834. print(BestNumber+Worst number)
  835. BestFunction()
  836. -- output will say 25
  837. Beginner's Roblox Scripting Tutorial #6 - Scope & Returning
  838. local a = 2
  839.  
  840. local function Test1()
  841. print (a)
  842. end
  843.  
  844. local function Test2()
  845.     print (a)
  846. end
  847. Test1()
  848. Test2()
  849. --------------------------------------------------
  850. local function hi()
  851. print (hi)
  852.  
  853. return "Awesome"
  854. end
  855.  
  856. local Hotdog = hi()
  857. print(Hotdog)
  858. -- this will return awesome
  859. ----------------------------------------------
  860. function testReturn()
  861.     return "This is a test!"
  862. end
  863. local returnedValue = testReturn() -- We've called the function, necessary for the functions to work.
  864. print(returnedValue)
  865.  
  866.  
  867. Beginner's Roblox Scripting Tutorial #7
  868.  
  869.  
  870.  
  871. Beginner's Roblox Scripting Tutorial #8 - If Statements
  872. 3 types of if statements
  873. local x = 3
  874. if x == 3  then
  875.   print ("Yes")
  876. end
  877.  
  878. local x = 3
  879. local y = 9
  880. if x == 3 and y == 9 then
  881.   print("Yes ")
  882. end
  883.  
  884. local x = 2
  885. local y = 6
  886. if x == 3 or y == 6 then
  887. print("Yes ")
  888. -- it will print yes cuz 1 is correct
  889.  
  890.   local Baseplate = game.Workspace.Baseplate
  891. if Baseplate.Anchored == true then
  892. Baseplate.Anchored = false
  893. wait (2)
  894. Baseplate.Anchored = true
  895. end
  896.  
  897.  Beginner's Roblox Scripting Tutorial #9 - Else & Elseif Statements
  898. -- if the if statment is not true it will run a else statmente
  899. local Hotdogs =  3
  900. if Hotdogs == 3 then print ("Hotdogs is equal to 3")
  901. elseif
  902.   print ("Hotdogs is not equal to 3")
  903. end  
  904.  
  905. Beginner's Roblox Scripting Tutorial #10 - Events
  906.  
  907. game.Workspace.MyFavPart.Touched:Connect(function)
  908. -- this will see if somebody stepped on the part Touched:Connect is a way to connect the function
  909.  
  910.  
  911. Beginner's Roblox Scripting Tutorial #11 - Built-In Functions
  912.  
  913. local melon =  game.Workspace:FindFristChild("Hotdog")
  914. WaitForChild
  915.  
  916. Beginner's Roblox Scripting Tutorial #12 - While and Repeat Loops
  917. this is a regular loop
  918. local hotdogs = 1
  919.  
  920. while hotdogs < 5 do
  921.      hotdogs = hotdogs + 1
  922.      print ("Hello")
  923.      print (hotdogs)
  924. end
  925. -- if hotdogs are less then five do something
  926. you need to do the hotdogs = hotdogs + 1  unless it will go in an infinite loop
  927.  
  928. local hotdogs = 1
  929.  
  930. while hotdogs < 5 do
  931.      wait(1)
  932.      print ("Hello")
  933.      print (hotdogs)
  934. end
  935.  
  936. local hotdogs = 1
  937.  repeat
  938.   ("This is from the loop")
  939.  untile hotdogs == 3
  940.  
  941.  while hotdogs == 3 do
  942.  print ("This is from the loop")
  943. end
  944.  
  945.  local hotdogs = 1
  946.  
  947.  repeat wait() until game.Players
  948.  
  949. Beginner's Roblox Scripting Tutorial #14 - Instances
  950. local part = Instance.new("Part")
  951. part.Parent = game.Workspace
  952.  
  953. Beginner's Roblox Scripting Tutorial #15 - Breaks / Loop Breaking
  954. local raindropped = 0
  955.  
  956. while true do
  957.     if raindropped >= 1000 then
  958.         break
  959.     end
  960.     raindropped = raindropped +1
  961.     wait()
  962.     local Rain = Instance.new("Part",game.Workspace)
  963.     Rain.Position = Vector3.new(0,500,5)
  964.     Rain.Size = Vector3.new(1,1,1)
  965.     Rain.Material = "Glass"
  966.     Rain.Transparency = 0.50
  967.     Rain.Touched:Connect(function(hit)
  968.         if hit.Parent:FindFirstChild("Humanoid") then
  969.             hit.Parent.Humanoid.Health = 0
  970.         end
  971.     end)
  972.  
  973. end
  974. end
  975. Beginner's Roblox Scripting Tutorial #17 - Leaderboards / leaderstats
  976. game.Players.PlayerAdded:Connect(function(player)
  977.  
  978.  local leaderstats  = Instance.new("Folder",player)
  979.   leaderstats.Name = "leaderstats"
  980. local Points = Instance.new("IntValue, leaderstats")
  981.  Points.Name = "Points"
  982. end)
  983. -- this is how to make a point giver
  984. script.Parent.ClickDector.MouseClick:Connect(function(player)
  985.  local player Playerpoins = player.leaderstats.Points
  986.  PlayerPoints.Value = PlayerPoints.Value + 1
  987. end)
  988. Beginner's Roblox Scripting Tutorial #18 - Tables
  989. local OmletteIngredients = {"Ham , Egg , Cheese"}
  990.  
  991. print (Omlette Ingredient {1})-- will say ham
  992. print (Omlette Ingredient {2})-- will say egg
  993. print (Omlette Ingredient {3})-- will say cheese
  994. TABLE FUNCTIONS
  995. local OmletteIngredients = {"Ham , Egg , Cheese"}
  996.  
  997. table.concat()-- merge them all together
  998. table.remove()-- will remove something from a table
  999. table.sort()-- will sort least to greatest only if your using numbers in a table
  1000.  
  1001. table.remove,2)-- will remove egg
  1002.  
  1003. table.sort(Name of number table)
  1004.  
  1005. print(table.concat(OmeletteIngredients),""))
  1006.  
  1007. Beginner's Roblox Scripting Tutorial #19 - in pairs loop / pairs loop
  1008.  
  1009.  
  1010. Advanced Roblox Scripting Tutorial #1
  1011. -- add a tool in Workspace then add a part then name it Handle
  1012. -- put the tool in starter pack
  1013. local Tool = script.Parent
  1014.  
  1015. Tool.Activated:Connnect(function()
  1016.  local DestroyMe = game.Workspace.DestroyMe
  1017.    DestoryMe:Destroy()
  1018. end)
  1019. Advanced Roblox Scripting Tutorial #2 - Filtering Enabled
  1020. nothing
  1021. Advanced Roblox Scripting Tutorial #3 - Local Scripts
  1022. -- only could be used in file based explorer items
  1023. -- only the players could see that the server cant see it
  1024. --  basically you assign it to the player only
  1025.  
  1026. Advanced Roblox Scripting Tutorial #4 - Common Built-In Functions
  1027.  
  1028. local Parts = game.Workspace.Parts:GetChildren()
  1029. for i, v in pairs(Parts) do
  1030. v:Destroy()
  1031. wait(1)
  1032. end
  1033. --make a folder with 3 parts in it put in Workspace this will destroy th
  1034. will get all children and create a table using the children
  1035. ----------------------------------------------------------
  1036. local character = game.Worksapce:WaitForChild("mariyandog999)
  1037. will wait for mariyandog999 to join then will run the lines of codes
  1038. you could write 2 parameter in the () Ex:("Part", True)
  1039. ------------------------------------------------------------
  1040. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  1041. -- you need to write that code for you do anything including the repStorage
  1042. -- service is the major things with properties (like Chat, Workspace,Lighting, ServerS
  1043. -- there is also small services like Gamepass service
  1044. -- GetService() will see if its there if it is not there it will create it for you
  1045. The PlayerAdded event fires when a player enters the game. This is used to fire an event when a player joins a game, such as loading the player’s saved GlobalDataStore data.
  1046. -----------------------------------------------
  1047. local Part = game.Workspace.Part
  1048. Part:Clone()
  1049. Part.Parent = workspace
  1050. this will clone a part
  1051. ---------------------------------------------------------
  1052.  
  1053. Advanced Roblox Scripting Tutorial #5 - Mouse (Beginner to Pro 2019)
  1054. you need to use a local script to get the mouse and in StarterPack
  1055. local player = game.Players.LocalPlayer -- way to get your player  find who he is
  1056. local mouse = player:GetMouse()--
  1057. mouse.Button1Down:Connect(function()
  1058. print("player clicked mouse")
  1059. end
  1060. local player = game.Players.LocalPlayer -- way to get your player  find who he is
  1061. local mouse = player:GetMouse()--
  1062. mouse.Move:Connect(function()
  1063.     print(mouse.Target)
  1064.    
  1065. end)
  1066. Advanced Roblox Scripting Tutorial #5.5 - Roblox Dev Forum & Wiki
  1067. this just simply just a place for scripting and news for roblox
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076. Advanced Roblox Scripting Tutorial #6 - UserInputService (Beginner to Pro 2019)
  1077. its like when a player presses a key
  1078. Input is like if i press C or space that is input
  1079. The primary purpose of this service is to allow for games to cooperate with multiple forms of available input - such as gamepads, touch screens, and keyboards. It allows a LocalScript to perform different actions depending on the device, and in turn, helps developers provide the best experience for the end user.
  1080. The UserInputService is a service used to detect and capture the different types of input available on a user’s device.
  1081. - create a local script then put it in starterplayerscripts
  1082. https://developer.roblox.com/en-us/api-reference/class/UserInputService
  1083. copy and paste that link to learn more about UserInputService
  1084. UserInPutServoce = game:GetService("UserInPutService")
  1085. UserInPutService.InputBegan:Connect(function(input,gameProccesedEvent)
  1086. if input.KeyCode == Enum -- is like a list touchInput,KeyboardInput).KeyCode.A then --you could put any key in the spot i typed A
  1087.    print("Player pressed A")
  1088. end
  1089. end)
  1090. -- enum is like a array of datas which you can choose from
  1091. ------------------------------------------
  1092. gameProcessedEvent is like if I make a giu and i click it the ourput will say true , but false if i am interacting with just the air
  1093. ----------------
  1094. if UserInputService.KeyBoardEnabled then
  1095. print("you have a mouse connected")
  1096. end
  1097. if UserInputService.TouchEnabled then
  1098. print("you have a touch screen connected")
  1099. end
  1100. if UserInputService.GamepadEnabled then
  1101. print("you have a gamepad screen connected")
  1102. if UserInputService.MouseEnabled then
  1103. print("you have a mousescreen connected")
  1104.  
  1105. Advanced Roblox Scripting Tutorial #7 - CFrame (Beginner to Pro 2019)
  1106. -- Cframe is data you use to rotate positio 3rd objects
  1107. -- stores position and orientation in 1
  1108. local part = script.Parent
  1109. print(part.Cframe)
  1110. -------------
  1111. local Part = script.Parent
  1112.  
  1113. local NewCframe = Cframe.new(0,10,0)
  1114.  
  1115. Part.Cframe = part.Cframe * NewCframe  
  1116.  
  1117. Advanced Roblox Scripting Tutorial #8 - Remote Events & Remote Functions
  1118. use DeletePart-- name of remoteEvent:FireServer(Part--parameter you are using on) will fire the remote event
  1119. -- they are used to let scripts on the server and local scripts on the client communicate
  1120.  
  1121. SomeLocalScript ~~~~~~~ RemoteEvent ~~~~~~ SomeServerScript
  1122. -- make a remote Event in RepStorage so clients and workspace can access it name it DeletePart and add a Part in the workspace
  1123. --  IF YOU DONT USE REMOTE EVENTS LOCAL SCRIPTS WILL ONLY FIRE FOR 1 PLAYER
  1124. -- remote events transfer data from local scripts to the RemoteEvent itself and finally will traverse the data to some a ServerScript
  1125. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  1126. local DeletePart = ReplicatedStorage:WaitForChild("DeletePart")-- this line of code will wait for the DeletePart
  1127. local UIS = game:GetService("UserInputService")
  1128. local Part = game.Workspace.Part
  1129.  
  1130. UIS.InputBegan:Connect(function(input, gameProcessedEvent)
  1131. if input.KeyCode == Enum.KeyCode.Delete then -- if players clicks the delete key on thier keyboard the print will fire
  1132. print("Delete Key was pressed")
  1133. DeletePart:FireServer(Part)
  1134.  
  1135.  
  1136.  
  1137.     end
  1138. end)
  1139. -- NOW I AM MAKING another script
  1140. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  1141. local DeletePart = ReplicatedStorage:WaitForChild("DeletePart")
  1142. DeletePart.OnServerEvent:Connect(function(player, part)-- this line of code will see if the Delete:FireServer(Part) script ran if it ran this line of code will fire and go on.OnServerEvent is a normal event , but you need to put player as the first parameter and the second parameter will be the Part in the workspace cuz we are deleting that part.
  1143.     Part:Destroy()
  1144. end)
  1145. ------------------------------------------------------------
  1146. Now Remote Functions
  1147. DeletePartFunction-- name of remoteFunction:InvokedServer(Part)
  1148. -----------------------------------------------------------
  1149. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  1150. local DeletePart = ReplicatedStorage:WaitForChild("DeletePart")
  1151. local Part = game.Workspace.Part
  1152. local UIS = game:GetService("UserInputService")
  1153.  
  1154.  
  1155.  
  1156. UIS.InputBegan:Connect(function(input, gameProcessedEvent)
  1157.     if input.KeyCode == Enum.KeyCode.Delete then
  1158.         print("player pressed delete key")
  1159.         DeletePart:OnServerInvoked(Part)
  1160.     end
  1161. end)
  1162. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  1163. local DeletePartFunction = game.ReplicatedStorage:WaitForChild("DeletePartFunction")
  1164. DeletePart.OnServerInvoked = function(player, Part
  1165.    
  1166.     Part:Destroy()
  1167. end)
  1168. Advanced Roblox Scripting Tutorial #9 - Welding (Beginner to Pro 2019)
  1169. -- welding is basically just making 2 parts move
  1170. - if 1 part moves then part 2 will move
  1171. [to weld go Model < View < then click create and then click weld
  1172. local bluePart = script.Parent
  1173.  
  1174. bluePart.Touched:Connect(function(hit)
  1175.     if hit.Parent:FindFirstChild("Humanoid")  then
  1176.         local head = hit.Parent.Head
  1177.         bluePart.CFrame = head.CFrame * CFrame.new(0,10,0)
  1178.         local weld = Instance.new("Weld")
  1179.         weld.Part0 = head
  1180.         weld.Part1 = bluePart
  1181.         weld.C0 = head.CFrame:Inverse()
  1182.         weld.C1 = bluePart.CFrame:Inverse()
  1183.         weld.Parent = script.Parent
  1184.     end
  1185. end)
  1186. Advanced Roblox Scripting Tutorial #10 - TweenService / Tween (Beginner to Pro 2019)    
  1187. -- Tweening makes parts bigger and bigger as time goes on
  1188. -- will change properties slowly of an object
  1189. local TweenService = game:GetService("TweenService")
  1190. local Part = script.Parent
  1191.  
  1192. local Info = TweenInfo.new(
  1193.     10,     --Lenght(seconds)
  1194.     Enum.EasingStyle.Sine,
  1195.     Enum.EasingDirection.Out,
  1196.     2,-- how much times you want it to do, --(reapet)
  1197.     false, -- Reverse(when ever you make it super big it will go back to normal
  1198.     1 -- delay between each tween(seconds)
  1199.  
  1200.  
  1201. )
  1202. local Goals =
  1203.     {
  1204.         Size = Vector3.new(15,15,15);
  1205.  
  1206.  
  1207.     }
  1208. local MakePartBiggerTween = TweenService:Create(Part,Info,Goals)
  1209. MakePartBiggerTween:Play()-- Play is the built in function used to play the tween
  1210. wait(10)
  1211. [the parameters mean]
  1212. - what you want to tween
  1213. -how do you want to do or how will the tween act
  1214.  
  1215. -What is the thing you want to achieve
  1216.  
  1217.  
  1218. -- don't put a comma at the end
  1219.  
  1220.  
  1221. {there is 3 EasingDirections}
  1222. - In
  1223. -Out
  1224. -InOut
  1225.  
  1226.  
  1227.  
  1228. {there is 8 EasingStyles}
  1229. they  determine how the tweening acts
  1230. -Linear
  1231. -Sine
  1232. -Back
  1233. -Quaf
  1234. -Quart
  1235. -Quint
  1236. -Bounce
  1237. -Elastic
  1238. L
  1239. E
  1240. E
  1241. T
  1242. R
  1243. D
  1244. Advanced Roblox Scripting Tutorial #11 - Module Scripts & Dictionaries
  1245. you could write code in a module and call it from another
  1246.  
  1247.  
  1248.  
  1249.  
  1250. local Dictionary = {
  1251. Cheese = "Cows",
  1252. Bread = "Wheat"
  1253.  
  1254.  
  1255.  
  1256. }
  1257.  
  1258. print(Dictionary.Cheese)
  1259. will print ("cow")
  1260. -------------------------------------------
  1261. insert module script in serverstorage
  1262. local module = { -- the module table
  1263. Dogs = "Cute, four-legged animals that love you"
  1264. Cats = "Mean, four-legged animals that kill"
  1265.  
  1266. }
  1267.  
  1268.  
  1269. return module
  1270. -- go to a script in workspace and type
  1271. local AnimalTable = require(game.ServerStorage.ModuleScript)-- require means get the table
  1272. print(AnimalTable.Dogs)
  1273. -----------------------------------------------------------------------------------------
  1274. Advanced Roblox Scripting Tutorial #12 - Lerp / Lerping
  1275. You could move a part like 20% of the way
  1276. local Part1 =  game.Workspace.Part1
  1277. local Part2 = game.Workspace.Part2
  1278. for i = 0,1.01 do
  1279. wait()
  1280. Part1.CFrame = Part1.Cframe:Lerp(Part.Cframe, .5
  1281. end
  1282.  
  1283. Advanced Roblox Scripting Tutorial #13 - Data Store / Saving Player Data
  1284.  
  1285.  
  1286. ---------------------------------------------------
  1287. local DataStore = game:GetService("DataStoreService")
  1288. local MyDataStore = DataStore:GetDataStore("MyDataStore")
  1289.  
  1290.  
  1291. game.Players.PlayerAdded:Connect(function(player)
  1292.     local leaderstats = Instance.new("Folder")
  1293.     leaderstats.Name = "leaderstats"
  1294.     leaderstats.Parent = player
  1295.    
  1296.    
  1297.     local Cash = Instance.new("IntValue")
  1298.     Cash.Name = "Cash"
  1299.    
  1300. Cash.Parent = leaderstats
  1301.     local PlayerId = "Player_"..player.UserId
  1302.     local data
  1303.     local success, errormessage = pcall(function()
  1304.        
  1305.     data = MyDataStore:GetAsync(PlayerId)-- your are storing the data in the player's user id
  1306.     end)-- GetAsync is a built in function that will load data and communicates with the data store which
  1307.     if success then
  1308.         Cash.Value = data
  1309.        
  1310.     end
  1311.  
  1312. end)
  1313.  
  1314. game.Players.PlayerRemoving:Connect(function(player)-- when a player gets removing the game will safe what he had in his leaderstats
  1315.     local PlayerId = "Player_"..player.UserId
  1316.    
  1317.     local data = player.leaderstats.Cash.Value -- will define data as what the player's leaderstats show
  1318.    
  1319.     local success, errormessage = pcall(function()
  1320.     MyDataStore:SetAsync(PlayerId, data)-- will Set the data that the player left with and permanent keep it on the player's Id
  1321.     end)
  1322.  
  1323. if success then
  1324.         print("Everything went flawless")
  1325.     else
  1326.         print("The script completely failed")
  1327. end
  1328. end)
  1329.  
  1330. Advanced Roblox Scripting Tutorial #14 - Animation
  1331.  
  1332. insert a R15 block rig and then start animating
  1333. when you make animation set the priority to Action
  1334.  
  1335. file < export < create new < name it < copy the link < go to the page and copy the animation id
  1336. -- you could only play animation in a local script
  1337. make sure to put an animation in your local script
  1338. -- paste your animation ID in your animation
  1339. local BirdAnimation = script.BirdAnimation
  1340. wait(10)
  1341. local player  = game.Players.LocalPlayer
  1342. local char = player.Character
  1343. local hum = char.Humanoid
  1344.  
  1345. local BirdAnimation = hum:LoadAnimation(BirdAnimation)
  1346. while true do
  1347. wait(1.35)
  1348. BirdAnimation:Play()
  1349. end
  1350.  
  1351.  
  1352. Advanced Roblox Scripting Tutorial #15 - Gamepasses | MarketplaceService
  1353.  
  1354. copy the game pass id
  1355. make a local script
  1356. local MPS = game:GetService("MarketplaceService")
  1357. local GamePassID = 17405519
  1358.  
  1359. local function promptPurchase()
  1360.     local player = game.Players.LocalPlayer
  1361.     local hasPass = false
  1362.     local success, message = pcall(function()
  1363.         hasPass = MPS:UserOwnsGamePassAsync(player.UserId, GamePassID)-- Built in function will check if the player owns the gamepass which player and which gamepass
  1364.         print(hasPass)-- if the player owns then the print will work if not then the PromptGamePassPurchase will run
  1365.     end)
  1366.     if hasPass == true then
  1367.         print("Player has it")
  1368.     else
  1369.         MPS:PromptGamePassPurchase(player, GamePassID)-- PromptGamePassPurchase will prompt the gamepass to the player
  1370.         print(player.Name)
  1371.         print(GamePassID)
  1372.     end
  1373. end
  1374. promptPurchase()
  1375. -- lines 11 through 14 will see if the player has the gamepass if they don't then the player will be prompted with the gamepas
  1376.  
  1377. ----------------------------------------------------
  1378. insert a server script
  1379. local GamePassID = 17405519
  1380. local ReplicatedStorage =  game:GetService("ReplicatedStorage")
  1381. local Sword = ReplicatedStorage:WaitForChild("ClassicSword")
  1382. local MPS = game:GetService("MarketplaceService")
  1383.  
  1384. MPS.PromptGamePassPurchaseFinished:Connect(function(player, purchasePassID, PurchaseSuccess)-- the Event will fire if the player click buys or cancesl when the gamepass shows up
  1385.     if PurchaseSuccess == true and purchasePassID == GamePassID then-- if the player clicked buy then you will give the sword
  1386.         print("Purchased the Pass")
  1387.         Sword.Parent = player.Character
  1388.     end
  1389.  
  1390.  
  1391. end)
  1392. --{ parameters of the event }
  1393. -- 1st parameter = The Player object for whom the prompt was shown
  1394. -- 2nd parameter = The ID number of the game pass shown in the prompt (not to be confused with an asset ID)
  1395. -- 3rd parameter = Whether the item was successfully purchased (false for errors and cancellations)
  1396.  
  1397. -----------------------------------------------
  1398. insert another script in script storage
  1399. local GamePassID = 17405519
  1400. local ReplicatedStorage =  game:GetService("ReplicatedStorage")
  1401. local Sword = ReplicatedStorage:WaitForChild("ClassicSword")
  1402. local MPS = game:GetService("MarketplaceService")
  1403.  
  1404. game.Players.PlayerAdded:Connect(function(player)
  1405.     wait(1)
  1406.     local char = game.Workspace:FindFirstChild(player.Name)
  1407.     local hasPass = false
  1408.  
  1409.     local success, errormessage = pcall(function()
  1410.         hasPass =  MPS:UserOwnsGamePassAsync(player.UserId, GamePassID)
  1411.     end)
  1412.     if success == true then
  1413.         print("player has the sword gamepass")
  1414.         Sword.Parent = char
  1415.     end
  1416. end)
  1417.  
  1418. Advanced Roblox Scripting Tutorial #16 - Developer Products
  1419. -- same thing as gamepass just you could buy them mutliple times
  1420. insert a local script
  1421. local MPS = game:GetService("MarketplaceService")
  1422. local Player = game:GetService("Players")
  1423.  
  1424. local ProductID = 1169157152
  1425. local player = game.Players.LocalPlayer
  1426.  
  1427. MPS:PromptProductPurchase(player, ProductID)
  1428.  
  1429. ----------------------------------------------------
  1430. local MPS = game:GetService("MarketplaceService")
  1431. local ProductID =  1169157152
  1432. local players = game:GetService("Players")
  1433. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  1434. local sword = game.ReplicatedStorage:WaitForChild("ClassicSword")
  1435. local productID2 = 92341432
  1436.  
  1437. local function processReceipt(receiptInfo)
  1438.    
  1439.     local player = players:GetPlayerByUserId(receiptInfo.PlayerId)
  1440.     if not player then
  1441.         -- 2312312
  1442.    
  1443.         return Enum.ProductPurchaseDecision.NotProcessedYet
  1444.        
  1445.     end
  1446.     if receiptInfo.ProductId == ProductID then
  1447.     if player then
  1448.  
  1449.         local char = game.Workspace:FindFirstChild(player.Name)
  1450.         local swordClone = sword:Clone()
  1451.         swordClone.Name = "Sword"
  1452.         swordClone.Parent = char
  1453.             end
  1454.     end
  1455.     return Enum.ProductPurchaseDecision.PurchaseGranted
  1456.    
  1457.    
  1458.    
  1459. end
  1460.  
  1461. MPS.ProcessReceipt = processReceipt
  1462.  
  1463.  
  1464.  
  1465. -- something to know is that it takes time
  1466. example: I was confused on gamepass/marketplaceserivce then i saw the 1 one of the comments it read
  1467. " I thought it was hard at first but after 2 days i understood it and it was easy
  1468.  
  1469. Advanced Roblox Scripting Tutorial #17 - Region3
  1470. insert a script in ServerScriptSerivce
  1471.  
  1472.  
  1473. local region = Region3.new(Vector3.new(0,0,0), Vector3.new(15,15,15))
  1474. local part = Instance.new("Part")
  1475. part.Anchored = true
  1476. part.Size = region.Size
  1477. part.Parent = game.Workspace
  1478.  
  1479. while true do
  1480.     wait()
  1481.     local PartInRegion = workspace:FindPartsInRegion3(region, part, 1000)
  1482.     for i, part in pairs(PartInRegion) do
  1483.         if part.Parent:FindFirstChild("Humanoid") ~= nil then
  1484.             print("player found in region"..part.Parent.Name)
  1485.             local char = part.Parent
  1486.             char.Humanoid:TakeDamage(char.Humanoid.MaxHealth)
  1487.     end
  1488. end
  1489. end
  1490.  
  1491. Advanced Roblox Scripting Tutorial #18 - Math Functions
  1492. math.floor(6.14378932749732) -- will round it to 6 rounds it to the lower value like if instead of 6.1 i wrote 6.9 it will still round it to 6
  1493. math.ceil(6.2321412412441) -- will round it to 7
  1494. math.huge() -- will get the highest number
  1495. math.rad()--  coverts degrees to radian  used in Cframe
  1496. math.pi()
  1497. math.pow(5,2) -- exponents will do 5 times five
  1498. math.abs(50) gives absolute value
  1499. --------------------------------------------------
  1500. Advanced Roblox Scripting Tutorial #19 - Sounds and Music
  1501. insert a script in serverscriptstorage
  1502. local Sound = game.Workspace.Sound
  1503. Sound:Play()
  1504. Sound:Pause()
  1505.  
  1506. -------------------------------------------
  1507. Advanced Roblox Scripting Tutorial #20 - Bindable Functions
  1508. insert a bindable function in repStorage -- name it GetList
  1509. insert a script in serverscriptservice
  1510. local GetList = game.ReplicatedStorage:WaitForChild("GetList")
  1511. local banList = {"UseCode_RainWay, UseCode_Tap"}
  1512. GetList.OnInvoke = function(player)
  1513. for i , v in pairs(banList) do
  1514. if v == player.Name then
  1515. print("player is in table")
  1516. return true
  1517. else
  1518. print("player is not on the list")
  1519. return false
  1520.      end
  1521.   end
  1522. end
  1523. --------------------
  1524. insert another script in serverscriptservice
  1525. local GetList = game.ReplicatedStorage:WaitForChild("GetList")
  1526. game.Players.PlayerAdded:Connect(function(player)
  1527. local IsPlayerBanned = GetList:Invoke(player)
  1528. if IsPlayerBanned == true then
  1529. player:Kick("You are banned")
  1530. end
  1531.  
  1532. Advanced Roblox Scripting Tutorial #21 - Pathfinding
  1533. insert a character
  1534. insert a script in the chracter
  1535. local PFS = game:GetService("PathfindingService")
  1536.  
  1537. local human = script.Parent:WaitForChild("Humanoid")
  1538. local torso = script.Parent:WaitForChild("Torso")
  1539.  
  1540. local path = PFS:CreatePath()
  1541. path:ComputeAsync(torso.Position, game.Workspace.endingPart.Position)  -- the 2 parameters are the starting a ending point where it shall start and finish
  1542. local waypoints = path:GetWaypoints()-- creates waypoints that lead to the end
  1543.  
  1544.  
  1545.  
  1546. for  i, waypoints in pairs(waypoints) do
  1547.     local part = Instance.new("Part")
  1548.         part.Shape = "Ball"
  1549.         part.Material = "Neon"
  1550.         part.Size = Vector3.new(0.6, 0.6 , 0.6)
  1551.         part.Position = waypoints.Position + Vector3.new(0,2,0)
  1552.         part.Anchored = true
  1553.         part.CanCollide = true
  1554.         part.Parent = game.Workspace
  1555.  
  1556.         if waypoints.Action == Enum.PathWaypointAction.Jump then
  1557.         human:ChangeState(Enum.HumanoidStateType.Jumping)
  1558.         end
  1559.        
  1560.         human:MoveTo(waypoints.Position)-- if just do this then it will not work you need need to generate a path then make it move to the waypoint generated path
  1561.         human.MoveToFinished:Wait(2)
  1562. end
  1563.  
  1564.  
  1565. human:MoveTo(game.Workspace.endingPart.Position)
  1566. if Enum.PathStatus.Success then
  1567.     print("The Robot Found it's way")
  1568. else
  1569.     print("The Robot Did not find it's way")
  1570. end
  1571.  
  1572. Advanced Roblox Scripting Tutorial #22 - Magnitude (Distance)
  1573. used to check the distance between things
  1574.  
  1575. local Part2  = game.Workspace.Part2
  1576. local mainPart = game.Workspace.mainPart
  1577. local distance = (Part2.Position - mainPart.Position).magnitude
  1578. print(distance)
  1579. --------------------------------------------
  1580. Advanced Roblox Scripting Tutorial #24 - Raycasting
  1581. insert a part
  1582. put a script in the part
  1583. local part = script.Parent
  1584.  
  1585. local FirstRay = Ray.new(part.Position, Vector3.new(0,50,0)) -- where you want it to start and end
  1586.     while wait(1) do
  1587.  
  1588.         local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(FirstRay, {part})
  1589.     if hit then
  1590.    
  1591.             print("Part was hit")
  1592.         else
  1593.             print("no")
  1594.         end
  1595.     end
  1596. --------------------------------------------------------------------------------------------
  1597. local Rep = game:GetService("ReplicatedStorage")
  1598. local Bullet = Rep:WaitForChild("Bullet")
  1599.  
  1600. local turret = script.Parent
  1601.  
  1602. local FireRate = 0.5
  1603. local BulletDamage = 10
  1604. local BulletSpeed = 150
  1605. local AgroDist = 100
  1606.  
  1607. while wait(FireRate) do
  1608.    
  1609.    
  1610.     local target = nil
  1611.     for i, v in pairs(game.Workspace:GetChildren()) do -- will loop through the workspace then find the NPC's hum and tor
  1612.         local human = v:FindFirstChild("Humanoid")
  1613.         local torso = v:FindFirstChild("Torso")
  1614.         if human and torso and human.Health > 0 then
  1615.             if (torso.Position - turret.Position).magnitude < AgroDist  then -- if it is less then 100 then it will shoot
  1616.                 target = torso
  1617.                 print(target)
  1618.             end
  1619.         end
  1620.     end
  1621.     if target then
  1622.         local torso = target
  1623.         turret.CFrame = CFrame.new(turret.Position, torso.Position)
  1624.        
  1625.         local newBullet =  Bullet:Clone()
  1626.         newBullet.Position = turret.Position
  1627.         newBullet.Parent = game.Workspace
  1628.        
  1629.         newBullet.Velocity = turret.CFrame.LookVector * BulletSpeed
  1630.        
  1631.         newBullet.Touched:Connect(function(objecthit)
  1632.             local human = objecthit.Parent:FindFirstChild("Humanoid")
  1633.             if human then
  1634.                 human:TakeDamage(BulletDamage)
  1635.    
  1636.                
  1637.                    
  1638.                         end
  1639.                    
  1640.            
  1641.         end)
  1642.        
  1643.     end
  1644. end
  1645. --------------------------------------------------------------------
  1646. Advanced Roblox Scripting Tutorial #25 - Teleport Service
  1647.  
  1648. local TP = game:GetService("TeleportService")
  1649. local part = script.Parent
  1650.  
  1651. part.Touched:Connect(function()
  1652. local human = hit.Parent:FindFirstChild("Humanoid")
  1653. if human then
  1654. local char = hit.Parent
  1655. local player = game.Players:GetPlayerFromCharacter(char)
  1656. TP:Teleport(-- what ever the game ID is, player)
  1657.  
  1658. end
  1659. end)
  1660. Advanced Roblox Scripting Tutorial #26 - ContextActionServic
  1661. -A context is simply a condition during which a player may perform some action. like holding a tool
  1662. - make a local script
  1663. local CAS = game:GetService("ContextActionService")
  1664.  
  1665. local part = game.Workspace.Part
  1666.  
  1667. local function onButtonPress()
  1668.   part.BrickColor = BrickColor.new("New Yeller")
  1669. end
  1670.  
  1671. CAS:BindAction("turnBrickYellow",onButtonPress, true, "T")
  1672. -- will show a button for mobile
  1673. wait(5)
  1674. CAS:UnbindAction("turnBrickYellow")
  1675. ---------------------------------------
  1676. Advanced Roblox Scripting Tutorial #27 - OrderedDataStores
  1677. local DataStore = game:GetService("DataStoreService")
  1678. local PlayerLevels = DataStore:GetOrderedDataStore("PlayerLevels")
  1679.  
  1680. local scores = {
  1681.     ["MarkGamerZobieHunter312414"] = 154,
  1682.     ["SallyWacky"] = 255,
  1683.     ["NancyPlays"] = 7,
  1684.     ["UseCodeTap"] = 57,
  1685.     ["Sus"] = 412
  1686. }
  1687. for player, level in pairs(scores) do
  1688.     PlayerLevels:SetAsync(player, level)
  1689. end
  1690.  
  1691. local pages = PlayerLevels:GetSortedAsync(false, 3)
  1692. print(pages)
  1693. while wait do
  1694.     local data = pages:GetCurrentPage()
  1695. print(data)
  1696.     for i, v in pairs(data) do
  1697.         print(v.key)
  1698.     end
  1699.     if pages.IsFinished then
  1700.         break
  1701.     else
  1702.         print("Next")
  1703.         pages:AdvanceToNextPageAsync()
  1704.  
  1705.     end
  1706. end
  1707. -------------------------------------------------------
  1708. Advanced Roblox Scripting Tutorial #28 - Camera Manipulation
  1709. wait(5)
  1710. local Cam = workspace.CurrentCamera
  1711. local player = game.Players.LocalPlayer
  1712. local FocusPart = game.Workspace.FocusPart
  1713.  
  1714. Cam.CameraType = "Fixed"
  1715. Cam.Focus = FocusPart.CFrame
  1716.  
  1717. wait(3)
  1718. Cam.CameraType = "Custom"
  1719. Cam.CameraSubject = player.Character.Humanoid
  1720. ----------------------------------------------
  1721. Advanced Roblox Scripting Tutorial #29 - RunService
  1722. local RunService = game:GetService("RunService")
  1723.  
  1724. RunService.HeartBeat:Connect(function()
  1725. print("Hi")
  1726. end
  1727.  
  1728.  
  1729. Advanced Roblox Scripting Tutorial #34 - MessagingService
  1730. -- global server communication at the same time
  1731. insert 2 server scripts
  1732. local Message = game:GetService("MessagingService")
  1733.  
  1734. Message:SubscribeAsync("PlayerFoundItemAnnouncement", function(message) -- subscribe to a topic the 1st parameter is the Topic, the 2nd paramter is a function the data is being sent the function so you could put a paramter in the function to use the data later on
  1735. print(message.Data)
  1736. print(message.Sent)
  1737. end)
  1738. wait(5)
  1739. Message:PublishAsync("PlayerFoundItemAnnouncement","Hello gamers")
  1740. Advanced Roblox Scripting Tutorial #33 - Coroutine
  1741. -- create threads -- like a new script
  1742. -- you could print things at the same time
  1743.  
  1744. local Thread = coroutine.create(function()
  1745. print("Cookies")
  1746. end)
  1747. coroutine.resume(Thread)
  1748. print("Ice Cream")
  1749.  
  1750.  
  1751. -- you could stop coroutines by doing
  1752. local NewThread = coroutine.wrap(function()
  1753. print("Started")
  1754. coroutine.yield()
  1755. print("Started Again")
  1756. NewThread()
  1757. --------------------------------------
  1758. OOP in Roblox #2 - Intro to Metatables
  1759. more powerful version of a table
  1760. you could have metamethods in the metatable
  1761. -- metamethods are like tables
  1762. local myTable = {2,432,44,45}
  1763.  
  1764.  
  1765.     local myMetaTable = {
  1766.  
  1767.  
  1768.     __index = function(table,index)--Fires when table[index] is indexed, if table[index] is nil. Can also be set to a table, in which case that table will be indexed.
  1769.         print("No data at this index")
  1770.         return 1 -- back up option
  1771.     end
  1772.  
  1773.  
  1774. }
  1775.  
  1776. --print(myTable[5])-- will print nil
  1777. -- cuz there is not 4th index so it will print nil but then it could scan the metaTable and give the data from the metaTable
  1778.  
  1779.  
  1780. setmetatable(myTable,myMetaTable)-- connecting the table to the metatable
  1781.  
  1782. local MyNum = myTable[5]
  1783. local anotherNum = MyNum * 5
  1784. print(MyNum,anotherNum)-- instead of crashing a metable will return a default value instead
  1785. ------------------------
  1786. CUSTOM PROPERTIES - Roblox Attributes Tutorial
  1787. -- allows you to have custom properties
  1788. -- go to the properties and click AddAttributes
  1789. local Debounce = false
  1790. script.Parent.Touched:Connect(function(hit)
  1791. local isPlayer = game.Players:GetPlayerFromCharacter(hit.Parent)
  1792.  
  1793. if isPlayer and (not Debounce) then
  1794. Debounce = true
  1795. hit.Parent.Humanoid:TakeDamage(script.Parent:GetAttribute("Damage"))
  1796. wait(2)
  1797. Debounce = false
  1798. end
  1799. end)
  1800.  
  1801. ROBLOX Building - How to use all Physics & Constraints - Part 1
  1802. Attachment Constraint
  1803. -- you could place attachments to parent a part
  1804. Ball in Socket Constrain
  1805. -- could allow 2 parts to rotate 2 freely when stucj together basically a cool weld, used for making advanched ligts
  1806. Hinge Constraint
  1807. -- allow attachments to rotate on 1 axis freely and you could create movement and velocity like a door.
  1808. -- could use limits enabled
  1809. Prismatic Constraint
  1810. allows a part to slide along 1 axis,   !------!
  1811. Cylindrical Constraint
  1812. -- same thing as Prismatic you it could just spin
  1813. Rope Constraints
  1814. -- basically just a rope you could attach it to a part to make it move in a rope physics
  1815. Rod Constraints
  1816. -- same thing just has limits enabled, but the rod is not lose stays at the same length forever will not contract
  1817. Spring Constraints
  1818. --aplies a force when it compress and works like a spring. could make cars with it
  1819. Weld Constraints
  1820. -- allows 2 parts to be weld
  1821. NoCollision Constraints
  1822. -- you could move parts through the part will only work with the specified part that you put the NoCollision Constraints
  1823.  
  1824. ROBLOX Building - How to use all Physics & Constraints - Part 2
  1825. most of these apply velocity and movement
  1826.  
  1827. Align Orientation
  1828. -- will apply movement make parts move and bounce like a soccer ball mostly rotate like one
  1829. Align Position
  1830. -- will push the parts together works like a magnet will met at the middle of constraints line
  1831. Vector Force
  1832. -- apply directional force, gravitional pull
  1833. Line Force
  1834. -- same thing as vectorForce
  1835. Torque
  1836. -- will find the center of the part and will add a force making the part spin
  1837. Angular Velocity
  1838. --apply force to part so a part has a constant Angular Velocity, you could make parts travel like this
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement