mariyandog999

Scripter Role

Jun 12th, 2021
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 29.16 KB | None | 0 0
  1. DevKing scripting
  2.  
  3. Beginner's Roblox Scripting Tutorial #3 - Variables
  4.  
  5. local Myname
  6. local HotDog = 4
  7.  
  8. The variable is the word after the local
  9. like HotDog
  10.  
  11. Beginner's Roblox Scripting Tutorial #4 - Arithmetic + Object-Oriented Programming
  12.  
  13. print (10 + 10)
  14. --output will say 20
  15. local Baseplate = game.Workspace.Baseplate
  16. Baseplate.material ="Wood"
  17. if there is a check you need to say = true or false
  18. -- way to adjust properties
  19.  
  20. Beginner's Roblox Scripting Tutorial #5 - Functions
  21. local function BestFunction()
  22.  
  23. local best number = 10
  24. local worst number = 15
  25.  
  26. print(BestNumber+Worst number)
  27. BestFunction()
  28. -- output will say 25
  29. Beginner's Roblox Scripting Tutorial #6 - Scope & Returning
  30. local a = 2
  31.  
  32. local function Test1()
  33. print (a)
  34. end
  35.  
  36. local function Test2()
  37.     print (a)
  38. end
  39. Test1()
  40. Test2()
  41. --------------------------------------------------
  42. local function hi()
  43. print (hi)
  44.  
  45. return "Awesome"
  46. end
  47.  
  48. local Hotdog = hi()
  49. print(Hotdog)
  50. -- this will return awesome
  51. ----------------------------------------------
  52. function testReturn()
  53.     return "This is a test!"
  54. end
  55. local returnedValue = testReturn() -- We've called the function, necessary for the functions to work.
  56. print(returnedValue)
  57.  
  58.  
  59. Beginner's Roblox Scripting Tutorial #7
  60.  
  61.  
  62.  
  63. Beginner's Roblox Scripting Tutorial #8 - If Statements
  64. 3 types of if statements
  65. local x = 3
  66. if x == 3  then
  67.   print ("Yes")
  68. end
  69.  
  70. local x = 3
  71. local y = 9
  72. if x == 3 and y == 9 then
  73.   print("Yes ")
  74. end
  75.  
  76. local x = 2
  77. local y = 6
  78. if x == 3 or y == 6 then
  79. print("Yes ")
  80. -- it will print yes cuz 1 is correct
  81.  
  82.   local Baseplate = game.Workspace.Baseplate
  83. if Baseplate.Anchored == true then
  84. Baseplate.Anchored = false
  85. wait (2)
  86. Baseplate.Anchored = true
  87. end
  88.  
  89.  Beginner's Roblox Scripting Tutorial #9 - Else & Elseif Statements
  90. -- if the if statment is not true it will run a else statmente
  91. local Hotdogs =  3
  92. if Hotdogs == 3 then print ("Hotdogs is equal to 3")
  93. elseif
  94.   print ("Hotdogs is not equal to 3")
  95. end  
  96.  
  97. Beginner's Roblox Scripting Tutorial #10 - Events
  98.  
  99. game.Workspace.MyFavPart.Touched:Connect(function)
  100. -- this will see if somebody stepped on the part Touched:Connect is a way to connect the function
  101.  
  102.  
  103. Beginner's Roblox Scripting Tutorial #11 - Built-In Functions
  104.  
  105. local melon =  game.Workspace:FindFristChild("Hotdog")
  106. WaitForChild
  107.  
  108. Beginner's Roblox Scripting Tutorial #12 - While and Repeat Loops
  109. this is a regular loop
  110. local hotdogs = 1
  111.  
  112. while hotdogs < 5 do
  113.      hotdogs = hotdogs + 1
  114.      print ("Hello")
  115.      print (hotdogs)
  116. end
  117. -- if hotdogs are less then five do something
  118. you need to do the hotdogs = hotdogs + 1  unless it will go in an infinite loop
  119.  
  120. local hotdogs = 1
  121.  
  122. while hotdogs < 5 do
  123.      wait(1)
  124.      print ("Hello")
  125.      print (hotdogs)
  126. end
  127.  
  128. local hotdogs = 1
  129.  repeat
  130.   ("This is from the loop")
  131.  untile hotdogs == 3
  132.  
  133.  while hotdogs == 3 do
  134.  print ("This is from the loop")
  135. end
  136.  
  137.  local hotdogs = 1
  138.  
  139.  repeat wait() until game.Players
  140.  
  141. Beginner's Roblox Scripting Tutorial #14 - Instances
  142. local part = Instance.new("Part")
  143. part.Parent = game.Workspace
  144.  
  145. Beginner's Roblox Scripting Tutorial #15 - Breaks / Loop Breaking
  146. local raindropped = 0
  147.  
  148. while true do
  149.     if raindropped >= 1000 then
  150.         break
  151.     end
  152.     raindropped = raindropped +1
  153.     wait()
  154.     local Rain = Instance.new("Part",game.Workspace)
  155.     Rain.Position = Vector3.new(0,500,5)
  156.     Rain.Size = Vector3.new(1,1,1)
  157.     Rain.Material = "Glass"
  158.     Rain.Transparency = 0.50
  159.     Rain.Touched:Connect(function(hit)
  160.         if hit.Parent:FindFirstChild("Humanoid") then
  161.             hit.Parent.Humanoid.Health = 0
  162.         end
  163.     end)
  164.  
  165. end
  166. end
  167. Beginner's Roblox Scripting Tutorial #17 - Leaderboards / leaderstats
  168. game.Players.PlayerAdded:Connect(function(player)
  169.  
  170.  local leaderstats  = Instance.new("Folder",player)
  171.   leaderstats.Name = "leaderstats"
  172. local Points = Instance.new("IntValue, leaderstats")
  173.  Points.Name = "Points"
  174. end)
  175. -- this is how to make a point giver
  176. script.Parent.ClickDector.MouseClick:Connect(function(player)
  177.  local player Playerpoins = player.leaderstats.Points
  178.  PlayerPoints.Value = PlayerPoints.Value + 1
  179. end)
  180. Beginner's Roblox Scripting Tutorial #18 - Tables
  181. local OmletteIngredients = {"Ham , Egg , Cheese"}
  182.  
  183. print (Omlette Ingredient {1})-- will say ham
  184. print (Omlette Ingredient {2})-- will say egg
  185. print (Omlette Ingredient {3})-- will say cheese
  186. TABLE FUNCTIONS
  187. local OmletteIngredients = {"Ham , Egg , Cheese"}
  188.  
  189. table.concat()-- merge them all together
  190. table.remove()-- will remove something from a table
  191. table.sort()-- will sort least to greatest only if your using numbers in a table
  192.  
  193. table.remove,2)-- will remove egg
  194.  
  195. table.sort(Name of number table)
  196.  
  197. print(table.concat(OmeletteIngredients),""))
  198.  
  199. Beginner's Roblox Scripting Tutorial #19 - in pairs loop / pairs loop
  200.  
  201.  
  202. Advanced Roblox Scripting Tutorial #1
  203. -- add a tool in Workspace then add a part then name it Handle
  204. -- put the tool in starter pack
  205. local Tool = script.Parent
  206.  
  207. Tool.Activated:Connnect(function()
  208.  local DestroyMe = game.Workspace.DestroyMe
  209.    DestoryMe:Destroy()
  210. end)
  211. Advanced Roblox Scripting Tutorial #2 - Filtering Enabled
  212. nothing
  213. Advanced Roblox Scripting Tutorial #3 - Local Scripts
  214. -- only could be used in file based explorer items
  215. -- only the players could see that the server cant see it
  216. --  basically you assign it to the player only
  217.  
  218. Advanced Roblox Scripting Tutorial #4 - Common Built-In Functions
  219.  
  220. local Parts = game.Workspace.Parts:GetChildren()
  221. for i, v in pairs(Parts) do
  222. v:Destroy()
  223. wait(1)
  224. end
  225. --make a folder with 3 parts in it put in Workspace this will destroy th
  226. will get all children and create a table using the children
  227. ----------------------------------------------------------
  228. local character = game.Worksapce:WaitForChild("mariyandog999)
  229. will wait for mariyandog999 to join then will run the lines of codes
  230. you could write 2 parameter in the () Ex:("Part", True)
  231. ------------------------------------------------------------
  232. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  233. -- you need to write that code for you do anything including the repStorage
  234. -- service is the major things with properties (like Chat, Workspace,Lighting, ServerS
  235. -- there is also small services like Gamepass service
  236. -- GetService() will see if its there if it is not there it will create it for you
  237. 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.
  238. -----------------------------------------------
  239. local Part = game.Workspace.Part
  240. Part:Clone()
  241. Part.Parent = workspace
  242. this will clone a part
  243. ---------------------------------------------------------
  244.  
  245. Advanced Roblox Scripting Tutorial #5 - Mouse (Beginner to Pro 2019)
  246. you need to use a local script to get the mouse and in StarterPack
  247. local player = game.Players.LocalPlayer -- way to get your player  find who he is
  248. local mouse = player:GetMouse()--
  249. mouse.Button1Down:Connect(function()
  250. print("player clicked mouse")
  251. end
  252. local player = game.Players.LocalPlayer -- way to get your player  find who he is
  253. local mouse = player:GetMouse()--
  254. mouse.Move:Connect(function()
  255.     print(mouse.Target)
  256.    
  257. end)
  258. Advanced Roblox Scripting Tutorial #5.5 - Roblox Dev Forum & Wiki
  259. this just simply just a place for scripting and news for roblox
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. Advanced Roblox Scripting Tutorial #6 - UserInputService (Beginner to Pro 2019)
  269. its like when a player presses a key
  270. Input is like if i press C or space that is input
  271. 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.
  272. The UserInputService is a service used to detect and capture the different types of input available on a user’s device.
  273. - create a local script then put it in starterplayerscripts
  274. https://developer.roblox.com/en-us/api-reference/class/UserInputService
  275. copy and paste that link to learn more about UserInputService
  276. UserInPutServoce = game:GetService("UserInPutService")
  277. UserInPutService.InputBegan:Connect(function(input,gameProccesedEvent)
  278. if input.KeyCode == Enum -- is like a list touchInput,KeyboardInput).KeyCode.A then --you could put any key in the spot i typed A
  279.    print("Player pressed A")
  280. end
  281. end)
  282. -- enum is like a array of datas which you can choose from
  283. ------------------------------------------
  284. 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
  285. ----------------
  286. if UserInputService.KeyBoardEnabled then
  287. print("you have a mouse connected")
  288. end
  289. if UserInputService.TouchEnabled then
  290. print("you have a touch screen connected")
  291. end
  292. if UserInputService.GamepadEnabled then
  293. print("you have a gamepad screen connected")
  294. if UserInputService.MouseEnabled then
  295. print("you have a mousescreen connected")
  296.  
  297. Advanced Roblox Scripting Tutorial #7 - CFrame (Beginner to Pro 2019)
  298. -- Cframe is data you use to rotate positio 3rd objects
  299. -- stores position and orientation in 1
  300. local part = script.Parent
  301. print(part.Cframe)
  302. -------------
  303. local Part = script.Parent
  304.  
  305. local NewCframe = Cframe.new(0,10,0)
  306.  
  307. Part.Cframe = part.Cframe * NewCframe  
  308.  
  309. Advanced Roblox Scripting Tutorial #8 - Remote Events & Remote Functions
  310. use DeletePart-- name of remoteEvent:FireServer(Part--parameter you are using on) will fire the remote event
  311. -- they are used to let scripts on the server and local scripts on the client communicate
  312.  
  313. SomeLocalScript ~~~~~~~ RemoteEvent ~~~~~~ SomeServerScript
  314. -- make a remote Event in RepStorage so clients and workspace can access it name it DeletePart and add a Part in the workspace
  315. --  IF YOU DONT USE REMOTE EVENTS LOCAL SCRIPTS WILL ONLY FIRE FOR 1 PLAYER
  316. -- remote events transfer data from local scripts to the RemoteEvent itself and finally will traverse the data to some a ServerScript
  317. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  318. local DeletePart = ReplicatedStorage:WaitForChild("DeletePart")-- this line of code will wait for the DeletePart
  319. local UIS = game:GetService("UserInputService")
  320. local Part = game.Workspace.Part
  321.  
  322. UIS.InputBegan:Connect(function(input, gameProcessedEvent)
  323. if input.KeyCode == Enum.KeyCode.Delete then -- if players clicks the delete key on thier keyboard the print will fire
  324. print("Delete Key was pressed")
  325. DeletePart:FireServer(Part)
  326.  
  327.  
  328.  
  329.     end
  330. end)
  331. -- NOW I AM MAKING another script
  332. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  333. local DeletePart = ReplicatedStorage:WaitForChild("DeletePart")
  334. 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.
  335.     Part:Destroy()
  336. end)
  337. ------------------------------------------------------------
  338. Now Remote Functions
  339. DeletePartFunction-- name of remoteFunction:InvokedServer(Part)
  340. -----------------------------------------------------------
  341. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  342. local DeletePart = ReplicatedStorage:WaitForChild("DeletePart")
  343. local Part = game.Workspace.Part
  344. local UIS = game:GetService("UserInputService")
  345.  
  346.  
  347.  
  348. UIS.InputBegan:Connect(function(input, gameProcessedEvent)
  349.     if input.KeyCode == Enum.KeyCode.Delete then
  350.         print("player pressed delete key")
  351.         DeletePart:OnServerInvoked(Part)
  352.     end
  353. end)
  354. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  355. local DeletePartFunction = game.ReplicatedStorage:WaitForChild("DeletePartFunction")
  356. DeletePart.OnServerInvoked = function(player, Part
  357.    
  358.     Part:Destroy()
  359. end)
  360. Advanced Roblox Scripting Tutorial #9 - Welding (Beginner to Pro 2019)
  361. -- welding is basically just making 2 parts move
  362. - if 1 part moves then part 2 will move
  363. [to weld go Model < View < then click create and then click weld
  364. local bluePart = script.Parent
  365.  
  366. bluePart.Touched:Connect(function(hit)
  367.     if hit.Parent:FindFirstChild("Humanoid")  then
  368.         local head = hit.Parent.Head
  369.         bluePart.CFrame = head.CFrame * CFrame.new(0,10,0)
  370.         local weld = Instance.new("Weld")
  371.         weld.Part0 = head
  372.         weld.Part1 = bluePart
  373.         weld.C0 = head.CFrame:Inverse()
  374.         weld.C1 = bluePart.CFrame:Inverse()
  375.         weld.Parent = script.Parent
  376.     end
  377. end)
  378. Advanced Roblox Scripting Tutorial #10 - TweenService / Tween (Beginner to Pro 2019)    
  379. -- Tweening makes parts bigger and bigger as time goes on
  380. -- will change properties slowly of an object
  381. local TweenService = game:GetService("TweenService")
  382. local Part = script.Parent
  383.  
  384. local Info = TweenInfo.new(
  385.     10,     --Lenght(seconds)
  386.     Enum.EasingStyle.Sine,
  387.     Enum.EasingDirection.Out,
  388.     2,-- how much times you want it to do, --(reapet)
  389.     false, -- Reverse(when ever you make it super big it will go back to normal
  390.     1 -- delay between each tween(seconds)
  391.  
  392.  
  393. )
  394. local Goals =
  395.     {
  396.         Size = Vector3.new(15,15,15);
  397.  
  398.  
  399.     }
  400. local MakePartBiggerTween = TweenService:Create(Part,Info,Goals)
  401. MakePartBiggerTween:Play()-- Play is the built in function used to play the tween
  402. wait(10)
  403. [the parameters mean]
  404. - what you want to tween
  405. -how do you want to do or how will the tween act
  406.  
  407. -What is the thing you want to achieve
  408.  
  409.  
  410. -- don't put a comma at the end
  411.  
  412.  
  413. {there is 3 EasingDirections}
  414. - In
  415. -Out
  416. -InOut
  417.  
  418.  
  419.  
  420. {there is 8 EasingStyles}
  421. they  determine how the tweening acts
  422. -Linear
  423. -Sine
  424. -Back
  425. -Quaf
  426. -Quart
  427. -Quint
  428. -Bounce
  429. -Elastic
  430. L
  431. E
  432. E
  433. T
  434. R
  435. D
  436. Advanced Roblox Scripting Tutorial #11 - Module Scripts & Dictionaries
  437. you could write code in a module and call it from another
  438.  
  439.  
  440.  
  441.  
  442. local Dictionary = {
  443. Cheese = "Cows",
  444. Bread = "Wheat"
  445.  
  446.  
  447.  
  448. }
  449.  
  450. print(Dictionary.Cheese)
  451. will print ("cow")
  452. -------------------------------------------
  453. insert module script in serverstorage
  454. local module = { -- the module table
  455. Dogs = "Cute, four-legged animals that love you"
  456. Cats = "Mean, four-legged animals that kill"
  457.  
  458. }
  459.  
  460.  
  461. return module
  462. -- go to a script in workspace and type
  463. local AnimalTable = require(game.ServerStorage.ModuleScript)-- require means get the table
  464. print(AnimalTable.Dogs)
  465. -----------------------------------------------------------------------------------------
  466. Advanced Roblox Scripting Tutorial #12 - Lerp / Lerping
  467. You could move a part like 20% of the way
  468. local Part1 =  game.Workspace.Part1
  469. local Part2 = game.Workspace.Part2
  470. for i = 0,1.01 do
  471. wait()
  472. Part1.CFrame = Part1.Cframe:Lerp(Part.Cframe, .5
  473. end
  474.  
  475. Advanced Roblox Scripting Tutorial #13 - Data Store / Saving Player Data
  476.  
  477.  
  478. ---------------------------------------------------
  479. local DataStore = game:GetService("DataStoreService")
  480. local MyDataStore = DataStore:GetDataStore("MyDataStore")
  481.  
  482.  
  483. game.Players.PlayerAdded:Connect(function(player)
  484.     local leaderstats = Instance.new("Folder")
  485.     leaderstats.Name = "leaderstats"
  486.     leaderstats.Parent = player
  487.    
  488.    
  489.     local Cash = Instance.new("IntValue")
  490.     Cash.Name = "Cash"
  491.    
  492. Cash.Parent = leaderstats
  493.     local PlayerId = "Player_"..player.UserId
  494.     local data
  495.     local success, errormessage = pcall(function()
  496.        
  497.     data = MyDataStore:GetAsync(PlayerId)-- your are storing the data in the player's user id
  498.     end)-- GetAsync is a built in function that will load data and communicates with the data store which
  499.     if success then
  500.         Cash.Value = data
  501.        
  502.     end
  503.  
  504. end)
  505.  
  506. game.Players.PlayerRemoving:Connect(function(player)-- when a player gets removing the game will safe what he had in his leaderstats
  507.     local PlayerId = "Player_"..player.UserId
  508.    
  509.     local data = player.leaderstats.Cash.Value -- will define data as what the player's leaderstats show
  510.    
  511.     local success, errormessage = pcall(function()
  512.     MyDataStore:SetAsync(PlayerId, data)-- will Set the data that the player left with and permanent keep it on the player's Id
  513.     end)
  514.  
  515. if success then
  516.         print("Everything went flawless")
  517.     else
  518.         print("The script completely failed")
  519. end
  520. end)
  521.  
  522. Advanced Roblox Scripting Tutorial #14 - Animation
  523.  
  524. insert a R15 block rig and then start animating
  525. when you make animation set the priority to Action
  526.  
  527. file < export < create new < name it < copy the link < go to the page and copy the animation id
  528. -- you could only play animation in a local script
  529. make sure to put an animation in your local script
  530. -- paste your animation ID in your animation
  531. local BirdAnimation = script.BirdAnimation
  532. wait(10)
  533. local player  = game.Players.LocalPlayer
  534. local char = player.Character
  535. local hum = char.Humanoid
  536.  
  537. local BirdAnimation = hum:LoadAnimation(BirdAnimation)
  538. while true do
  539. wait(1.35)
  540. BirdAnimation:Play()
  541. end
  542.  
  543.  
  544. Advanced Roblox Scripting Tutorial #15 - Gamepasses | MarketplaceService
  545.  
  546. copy the game pass id
  547. make a local script
  548. local MPS = game:GetService("MarketplaceService")
  549. local GamePassID = 17405519
  550.  
  551. local function promptPurchase()
  552.     local player = game.Players.LocalPlayer
  553.     local hasPass = false
  554.     local success, message = pcall(function()
  555.         hasPass = MPS:UserOwnsGamePassAsync(player.UserId, GamePassID)-- Built in function will check if the player owns the gamepass which player and which gamepass
  556.         print(hasPass)-- if the player owns then the print will work if not then the PromptGamePassPurchase will run
  557.     end)
  558.     if hasPass == true then
  559.         print("Player has it")
  560.     else
  561.         MPS:PromptGamePassPurchase(player, GamePassID)-- PromptGamePassPurchase will prompt the gamepass to the player
  562.         print(player.Name)
  563.         print(GamePassID)
  564.     end
  565. end
  566. promptPurchase()
  567. -- 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
  568.  
  569. ----------------------------------------------------
  570. insert a server script
  571. local GamePassID = 17405519
  572. local ReplicatedStorage =  game:GetService("ReplicatedStorage")
  573. local Sword = ReplicatedStorage:WaitForChild("ClassicSword")
  574. local MPS = game:GetService("MarketplaceService")
  575.  
  576. MPS.PromptGamePassPurchaseFinished:Connect(function(player, purchasePassID, PurchaseSuccess)-- the Event will fire if the player click buys or cancesl when the gamepass shows up
  577.     if PurchaseSuccess == true and purchasePassID == GamePassID then-- if the player clicked buy then you will give the sword
  578.         print("Purchased the Pass")
  579.         Sword.Parent = player.Character
  580.     end
  581.  
  582.  
  583. end)
  584. --{ parameters of the event }
  585. -- 1st parameter = The Player object for whom the prompt was shown
  586. -- 2nd parameter = The ID number of the game pass shown in the prompt (not to be confused with an asset ID)
  587. -- 3rd parameter = Whether the item was successfully purchased (false for errors and cancellations)
  588.  
  589. -----------------------------------------------
  590. insert another script in script storage
  591. local GamePassID = 17405519
  592. local ReplicatedStorage =  game:GetService("ReplicatedStorage")
  593. local Sword = ReplicatedStorage:WaitForChild("ClassicSword")
  594. local MPS = game:GetService("MarketplaceService")
  595.  
  596. game.Players.PlayerAdded:Connect(function(player)
  597.     wait(1)
  598.     local char = game.Workspace:FindFirstChild(player.Name)
  599.     local hasPass = false
  600.  
  601.     local success, errormessage = pcall(function()
  602.         hasPass =  MPS:UserOwnsGamePassAsync(player.UserId, GamePassID)
  603.     end)
  604.     if success == true then
  605.         print("player has the sword gamepass")
  606.         Sword.Parent = char
  607.     end
  608. end)
  609.  
  610. Advanced Roblox Scripting Tutorial #16 - Developer Products
  611. -- same thing as gamepass just you could buy them mutliple times
  612. insert a local script
  613. local MPS = game:GetService("MarketplaceService")
  614. local Player = game:GetService("Players")
  615.  
  616. local ProductID = 1169157152
  617. local player = game.Players.LocalPlayer
  618.  
  619. MPS:PromptProductPurchase(player, ProductID)
  620.  
  621. ----------------------------------------------------
  622. local MPS = game:GetService("MarketplaceService")
  623. local ProductID =  1169157152
  624. local players = game:GetService("Players")
  625. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  626. local sword = game.ReplicatedStorage:WaitForChild("ClassicSword")
  627. local productID2 = 92341432
  628.  
  629. local function processReceipt(receiptInfo)
  630.    
  631.     local player = players:GetPlayerByUserId(receiptInfo.PlayerId)
  632.     if not player then
  633.         -- 2312312
  634.    
  635.         return Enum.ProductPurchaseDecision.NotProcessedYet
  636.        
  637.     end
  638.     if receiptInfo.ProductId == ProductID then
  639.     if player then
  640.  
  641.         local char = game.Workspace:FindFirstChild(player.Name)
  642.         local swordClone = sword:Clone()
  643.         swordClone.Name = "Sword"
  644.         swordClone.Parent = char
  645.             end
  646.     end
  647.     return Enum.ProductPurchaseDecision.PurchaseGranted
  648.    
  649.    
  650.    
  651. end
  652.  
  653. MPS.ProcessReceipt = processReceipt
  654.  
  655.  
  656.  
  657. -- something to know is that it takes time
  658. example: I was confused on gamepass/marketplaceserivce then i saw the 1 one of the comments it read
  659. " I thought it was hard at first but after 2 days i understood it and it was easy
  660.  
  661. Advanced Roblox Scripting Tutorial #17 - Region3
  662. insert a script in ServerScriptSerivce
  663.  
  664.  
  665. local region = Region3.new(Vector3.new(0,0,0), Vector3.new(15,15,15))
  666. local part = Instance.new("Part")
  667. part.Anchored = true
  668. part.Size = region.Size
  669. part.Parent = game.Workspace
  670.  
  671. while true do
  672.     wait()
  673.     local PartInRegion = workspace:FindPartsInRegion3(region, part, 1000)
  674.     for i, part in pairs(PartInRegion) do
  675.         if part.Parent:FindFirstChild("Humanoid") ~= nil then
  676.             print("player found in region"..part.Parent.Name)
  677.             local char = part.Parent
  678.             char.Humanoid:TakeDamage(char.Humanoid.MaxHealth)
  679.     end
  680. end
  681. end
  682.  
  683. Advanced Roblox Scripting Tutorial #18 - Math Functions
  684. 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
  685. math.ceil(6.2321412412441) -- will round it to 7
  686. math.huge() -- will get the highest number
  687. math.rad()--  coverts degrees to radian  used in Cframe
  688. math.pi()
  689. math.pow(5,2) -- exponents will do 5 times five
  690. math.abs(50) gives absolute value
  691. --------------------------------------------------
  692. Advanced Roblox Scripting Tutorial #19 - Sounds and Music
  693. insert a script in serverscriptstorage
  694. local Sound = game.Workspace.Sound
  695. Sound:Play()
  696. Sound:Pause()
  697.  
  698. -------------------------------------------
  699. Advanced Roblox Scripting Tutorial #20 - Bindable Functions
  700. insert a bindable function in repStorage -- name it GetList
  701. insert a script in serverscriptservice
  702. local GetList = game.ReplicatedStorage:WaitForChild("GetList")
  703. local banList = {"UseCode_RainWay, UseCode_Tap"}
  704. GetList.OnInvoke = function(player)
  705. for i , v in pairs(banList) do
  706. if v == player.Name then
  707. print("player is in table")
  708. return true
  709. else
  710. print("player is not on the list")
  711. return false
  712.      end
  713.   end
  714. end
  715. --------------------
  716. insert another script in serverscriptservice
  717. local GetList = game.ReplicatedStorage:WaitForChild("GetList")
  718. game.Players.PlayerAdded:Connect(function(player)
  719. local IsPlayerBanned = GetList:Invoke(player)
  720. if IsPlayerBanned == true then
  721. player:Kick("You are banned")
  722. end
  723.  
  724. Advanced Roblox Scripting Tutorial #21 - Pathfinding
  725. insert a character
  726. insert a script in the chracter
  727. local PFS = game:GetService("PathfindingService")
  728.  
  729. local human = script.Parent:WaitForChild("Humanoid")
  730. local torso = script.Parent:WaitForChild("Torso")
  731.  
  732. local path = PFS:CreatePath()
  733. path:ComputeAsync(torso.Position, game.Workspace.endingPart.Position)  -- the 2 parameters are the starting a ending point where it shall start and finish
  734. local waypoints = path:GetWaypoints()-- creates waypoints that lead to the end
  735.  
  736.  
  737.  
  738. for  i, waypoints in pairs(waypoints) do
  739.     local part = Instance.new("Part")
  740.         part.Shape = "Ball"
  741.         part.Material = "Neon"
  742.         part.Size = Vector3.new(0.6, 0.6 , 0.6)
  743.         part.Position = waypoints.Position + Vector3.new(0,2,0)
  744.         part.Anchored = true
  745.         part.CanCollide = true
  746.         part.Parent = game.Workspace
  747.  
  748.         if waypoints.Action == Enum.PathWaypointAction.Jump then
  749.         human:ChangeState(Enum.HumanoidStateType.Jumping)
  750.         end
  751.        
  752.         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
  753.         human.MoveToFinished:Wait(2)
  754. end
  755.  
  756.  
  757. human:MoveTo(game.Workspace.endingPart.Position)
  758. if Enum.PathStatus.Success then
  759.     print("The Robot Found it's way")
  760. else
  761.     print("The Robot Did not find it's way")
  762. end
  763.  
  764. Advanced Roblox Scripting Tutorial #22 - Magnitude (Distance)
  765. used to check the distance between things
  766.  
  767. local Part2  = game.Workspace.Part2
  768. local mainPart = game.Workspace.mainPart
  769. local distance = (Part2.Position - mainPart.Position).magnitude
  770. print(distance)
  771. --------------------------------------------
  772. Advanced Roblox Scripting Tutorial #24 - Raycasting
  773. insert a part
  774. put a script in the part
  775. local part = script.Parent
  776.  
  777. local FirstRay = Ray.new(part.Position, Vector3.new(0,50,0)) -- where you want it to start and end
  778.     while wait(1) do
  779.  
  780.         local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(FirstRay, {part})
  781.     if hit then
  782.    
  783.             print("Part was hit")
  784.         else
  785.             print("no")
  786.         end
  787.     end
  788. --------------------------------------------------------------------------------------------
  789. local Rep = game:GetService("ReplicatedStorage")
  790. local Bullet = Rep:WaitForChild("Bullet")
  791.  
  792. local turret = script.Parent
  793.  
  794. local FireRate = 0.5
  795. local BulletDamage = 10
  796. local BulletSpeed = 150
  797. local AgroDist = 100
  798.  
  799. while wait(FireRate) do
  800.    
  801.    
  802.     local target = nil
  803.     for i, v in pairs(game.Workspace:GetChildren()) do -- will loop through the workspace then find the NPC's hum and tor
  804.         local human = v:FindFirstChild("Humanoid")
  805.         local torso = v:FindFirstChild("Torso")
  806.         if human and torso and human.Health > 0 then
  807.             if (torso.Position - turret.Position).magnitude < AgroDist  then -- if it is less then 100 then it will shoot
  808.                 target = torso
  809.                 print(target)
  810.             end
  811.         end
  812.     end
  813.     if target then
  814.         local torso = target
  815.         turret.CFrame = CFrame.new(turret.Position, torso.Position)
  816.        
  817.         local newBullet =  Bullet:Clone()
  818.         newBullet.Position = turret.Position
  819.         newBullet.Parent = game.Workspace
  820.        
  821.         newBullet.Velocity = turret.CFrame.LookVector * BulletSpeed
  822.        
  823.         newBullet.Touched:Connect(function(objecthit)
  824.             local human = objecthit.Parent:FindFirstChild("Humanoid")
  825.             if human then
  826.                 human:TakeDamage(BulletDamage)
  827.    
  828.                
  829.                    
  830.                         end
  831.                    
  832.            
  833.         end)
  834.        
  835.     end
  836. end
  837. --------------------------------------------------------------------
  838. Advanced Roblox Scripting Tutorial #25 - Teleport Service
  839.  
  840. local TP = game:GetService("TeleportService")
  841. local part = script.Parent
  842.  
  843. part.Touched:Connect(function()
  844. local human = hit.Parent:FindFirstChild("Humanoid")
  845. if human then
  846. local char = hit.Parent
  847. local player = game.Players:GetPlayerFromCharacter(char)
  848. TP:Teleport(-- what ever the game ID is, player)
  849.  
  850. end
  851. end)
  852. Advanced Roblox Scripting Tutorial #26 - ContextActionServic
  853. -A context is simply a condition during which a player may perform some action. like holding a tool
  854. - make a local script
  855. local CAS = game:GetService("ContextActionService")
  856.  
  857. local part = game.Workspace.Part
  858.  
  859. local function onButtonPress()
  860.   part.BrickColor = BrickColor.new("New Yeller")
  861. end
  862.  
  863. CAS:BindAction("turnBrickYellow",onButtonPress, true, "T")
  864. -- will show a button for mobile
  865. wait(5)
  866. CAS:UnbindAction("turnBrickYellow")
  867. ---------------------------------------
  868. Advanced Roblox Scripting Tutorial #27 - OrderedDataStores
  869. local DataStore = game:GetService("DataStoreService")
  870. local PlayerLevels = DataStore:GetOrderedDataStore("PlayerLevels")
  871.  
  872. local scores = {
  873.     ["MarkGamerZobieHunter312414"] = 154,
  874.     ["SallyWacky"] = 255,
  875.     ["NancyPlays"] = 7,
  876.     ["UseCodeTap"] = 57,
  877.     ["Sus"] = 412
  878. }
  879. for player, level in pairs(scores) do
  880.     PlayerLevels:SetAsync(player, level)
  881. end
  882.  
  883. local pages = PlayerLevels:GetSortedAsync(false, 3)
  884. print(pages)
  885. while wait do
  886.     local data = pages:GetCurrentPage()
  887. print(data)
  888.     for i, v in pairs(data) do
  889.         print(v.key)
  890.     end
  891.     if pages.IsFinished then
  892.         break
  893.     else
  894.         print("Next")
  895.         pages:AdvanceToNextPageAsync()
  896.  
  897.     end
  898. end
  899. -------------------------------------------------------
  900. Advanced Roblox Scripting Tutorial #28 - Camera Manipulation
  901. wait(5)
  902. local Cam = workspace.CurrentCamera
  903. local player = game.Players.LocalPlayer
  904. local FocusPart = game.Workspace.FocusPart
  905.  
  906. Cam.CameraType = "Fixed"
  907. Cam.Focus = FocusPart.CFrame
  908.  
  909. wait(3)
  910. Cam.CameraType = "Custom"
  911. Cam.CameraSubject = player.Character.Humanoid
  912. ----------------------------------------------
  913. Advanced Roblox Scripting Tutorial #29 - RunService
  914. local RunService = game:GetService("RunService")
  915.  
  916. RunService.HeartBeat:Connect(function()
  917. print("Hi")
  918. end
  919.  
  920.  
  921. Advanced Roblox Scripting Tutorial #34 - MessagingService
  922. -- global server communication at the same time
  923. insert 2 server scripts
  924. local Message = game:GetService("MessagingService")
  925.  
  926. 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
  927. print(message.Data)
  928. print(message.Sent)
  929. end)
  930. wait(5)
  931. Message:PublishAsync("PlayerFoundItemAnnouncement","Hello gamers")
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
Advertisement
Add Comment
Please, Sign In to add comment