Advertisement
Guest User

Apocalypse Rising 2 Spawning GUI

a guest
Jul 2nd, 2018
15,900
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.68 KB | None | 0 0
  1. --[[/////////////////////////////////////////Item Spawner by: Alasdair////////////////////////////////////////////
  2.  
  3. Instructions:
  4. 1.) Type item name or command (You don't have to type whole item name.)
  5. 2.) Press enter or "Spawn"
  6. 3.) Try to pick up the spawned item through the inventory gui. By right clicking it and clicking "Pick up"
  7. 4.) Another item will spawn on the ground for the server. This is the item you can pick up.
  8.  
  9. If an item doesn't spawn, drop any item on the ground first.
  10.  
  11.  
  12. Settings:
  13.  
  14. ]]
  15.  
  16. local kits = {
  17. ["RSG"] = {"AK-47", "Shirt_Windbreaker_04", "Pants_Track_04", "Rifle Scope", "Osprey Suppressor", "Military Ammo Vest Black", "Duffel Bag Red", "HatRedBeret", "Foregrip", "7.62x39mm AK 75rd Drum Magazine", "Uzi", "9x19mm 20rd Magazine Uzi", "Auto Injector", "Adrenaline", "Military Painkiller", "ACOG"};
  18. }
  19.  
  20.  
  21. --///////////////////////////////////////DONT EDIT ANYTHING BELOW THIS////////////////////////////////////////////
  22.  
  23. local spawner = Instance.new ("ScreenGui")
  24. local searchScrollFrame = Instance.new ("ScrollingFrame")
  25. local textBox = Instance.new ("TextBox")
  26. local textLabel = Instance.new("TextLabel")
  27. local spawnButton = Instance.new ("TextButton")
  28.  
  29. local client = game.Players.LocalPlayer
  30.  
  31. local itemToSpawn = nil
  32. local kitToSpawn = nil
  33.  
  34. spawner.Parent = game.Players.LocalPlayer.PlayerGui
  35.  
  36. searchScrollFrame.Size = UDim2.new (0, 250, 0, 100)
  37. searchScrollFrame.Position = UDim2.new (0.02, 0, 0.9, -105)
  38. searchScrollFrame.BackgroundTransparency = 1
  39. searchScrollFrame.Parent = spawner
  40.  
  41. textBox.Size = UDim2.new (0, 250, 0, 25)
  42. textBox.Position = UDim2.new (.02, 0, .9, 0)
  43. textBox.BackgroundColor3 = Color3.fromRGB(120,120,120)
  44. textBox.TextColor3 = Color3.fromRGB(255,255,255)
  45. textBox.BorderSizePixel = 0
  46. textBox.BackgroundTransparency = 0.5
  47. textBox.Text = "Put Item Name"
  48. textBox.TextXAlignment = Enum.TextXAlignment.Left
  49. textBox.Parent = spawner
  50.  
  51. textLabel.Size = UDim2.new (1, 0, 1, 0)
  52. textLabel.Position = UDim2.new (0, 0, 0, 0)
  53. textLabel.BackgroundTransparency = 1
  54. textLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
  55. textLabel.Text = "Put Item Name"
  56. textLabel.TextXAlignment = Enum.TextXAlignment.Left
  57. textLabel.Parent = textBox
  58.  
  59. spawnButton.Size = UDim2.new (0, 250, 0, 20)
  60. spawnButton.Position = UDim2.new (.02, 0, .9, 25)
  61. spawnButton.BackgroundColor3 = Color3.fromRGB(97, 189, 22)
  62. spawnButton.TextColor3 = Color3.fromRGB(255,255,255)
  63. spawnButton.BorderSizePixel = 0
  64. spawnButton.BackgroundTransparency = 0
  65. spawnButton.Text = ("Spawn")
  66. spawnButton.Parent = spawner
  67.  
  68. allLoot = {"delete_gui"}
  69.  
  70. for _, item in pairs (game.ReplicatedStorage.Assets.Loot:GetDescendants()) do
  71. if item:IsA("Model") then
  72. print (item)
  73. table.insert(allLoot, item.Name)
  74. end
  75. end
  76.  
  77. local search = function(text)
  78. local itemSearch = {}
  79.  
  80. for i, v in pairs (allLoot) do
  81. if text:upper() == v:sub(1, string.len(text)):upper() then
  82. table.insert(itemSearch, v)
  83. end
  84. end
  85.  
  86.  
  87. for i, v in pairs (kits) do
  88. print (i)
  89. if text:upper() == i:sub(1, string.len(text)):upper() then
  90. table.insert(itemSearch, i)
  91. end
  92. end
  93.  
  94. itemToSpawn = itemSearch[1]
  95.  
  96. return itemSearch
  97. end
  98.  
  99. local getChunk = function()
  100. local lootFolder = game.Workspace.Loot.Nodes
  101. for _, v in pairs (lootFolder:GetDescendants()) do
  102. if v:IsA("Model") then
  103. return v.Parent.Parent
  104. end
  105. end
  106. end
  107.  
  108. local spawnItem = function(name, chunk)
  109. local item = Instance.new ("CFrameValue")
  110. item.Name = name
  111. item.Value = game.Workspace.Characters[client.Name].Head.CFrame * CFrame.new (math.random(0,3), math.random(0,3), math.random(0,3))
  112.  
  113. item.Parent = chunk
  114. end
  115.  
  116. spawnKit = function(name, chunk)
  117. print ('spawn kit function running')
  118. for _, v in pairs (kits[name]) do
  119. spawnItem(v, chunk)
  120. end
  121. end
  122.  
  123. runCommand = function(name, chunk)
  124. if kits[name] ~= nil then
  125. spawnKit(name, chunk)
  126. elseif name == "delete_gui" then
  127. spawner:Destroy()
  128. script:Destroy()
  129. else
  130. spawnItem(name, chunk)
  131. end
  132. end
  133.  
  134. textBox.Changed:connect(function(Text)
  135. local itemsSearch = search(textBox.Text)
  136. if textBox.Text == "" or textBox.Text == " " or textBox.Text == "Put Item Name" or itemsSearch[1] == nil then return end
  137.  
  138. searchScrollFrame:ClearAllChildren()
  139. for i, v in pairs (itemsSearch) do
  140. print (v)
  141. local yPos = ((20 * i) - 20)
  142. local s = Instance.new('TextLabel', searchScrollFrame)
  143. s.BorderSizePixel = 0
  144. s.TextScaled = true
  145. s.Text = v
  146. s.Name = v
  147. s.BackgroundColor3 = Color3.fromRGB(120,120,120)
  148. s.BackgroundTransparency = 0.5
  149. s.TextColor3 = Color3.fromRGB(255, 255, 255)
  150. s.Size = UDim2.new(1, 0, 0, 20)
  151. s.Position = UDim2.new(0, 0, 0, yPos)
  152. searchScrollFrame.CanvasSize = UDim2.new(0, 0, 0, 20 * i)
  153. end
  154. textBox.Text = textBox.Text:upper()
  155. textLabel.Text = itemsSearch[1]:upper()
  156. end)
  157.  
  158. spawnButton.MouseButton1Click:connect(function()
  159. if textBox.Text ~= "" or textBox.Text ~= " " and itemToSpawn ~= nil then
  160. local chunk = getChunk()
  161. runCommand(itemToSpawn, chunk)
  162. itemToSpawn = nil
  163. end
  164. end)
  165.  
  166. textBox.FocusLost:connect(function(enter)
  167. if enter then
  168. if textBox.Text ~= "" or textBox.Text ~= " " then
  169. local chunk = getChunk()
  170. runCommand(itemToSpawn, chunk)
  171. itemToSpawn = nil
  172. end
  173. else
  174. searchScrollFrame:ClearAllChildren()
  175. searchScrollFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
  176. textLabel.Text = "Put Item Name"
  177. textBox.Text = "Put Item Name"
  178. end
  179. searchScrollFrame:ClearAllChildren()
  180. searchScrollFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
  181. textLabel.Text = "Put Item Name"
  182. textBox.Text = "Put Item Name"
  183. end)
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement