FuZionPlayz

apoc 2 spawn GUi

Jul 11th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.55 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 model 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. Adding a kit:
  12. 1.) Follow this format: ["Kit name"] = {"item name", "item name2", "item name3"}
  13. 2.) Make sure that all item names are typed correctly. It is CaSe SeNsItIvE!
  14.  
  15. Settings:
  16. ]]
  17.  
  18. local kits = {
  19. ["V3RM_Squad"] = {"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"};
  20. }
  21.  
  22. --///////////////////////////////////////DONT EDIT ANYTHING BELOW THIS////////////////////////////////////////////
  23.  
  24. local spawner = Instance.new ("ScreenGui")
  25. local searchScrollFrame = Instance.new ("ScrollingFrame")
  26. local textBox = Instance.new ("TextBox")
  27. local textLabel = Instance.new("TextLabel")
  28. local spawnButton = Instance.new ("TextButton")
  29.  
  30. local client = game.Players.LocalPlayer
  31.  
  32. local itemToSpawn = 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(80, 179, 50)
  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. for i, v in pairs (kits) do
  87. if text:upper() == i:sub(1, string.len(text)):upper() then
  88. table.insert(itemSearch, i)
  89. end
  90. end
  91.  
  92. itemToSpawn = itemSearch[1]
  93.  
  94. return itemSearch
  95. end
  96.  
  97. local getChunk = function()
  98. local lootFolder = game.Workspace.Loot.Nodes
  99. for _, v in pairs (lootFolder:GetDescendants()) do
  100. if v:IsA("Model") then
  101. return v.Parent.Parent
  102. end
  103. end
  104. end
  105.  
  106. local spawnItem = function(name, chunk)
  107. local item = Instance.new ("CFrameValue")
  108. item.Name = name
  109. item.Value = game.Workspace.Characters[client.Name].Head.CFrame * CFrame.new (math.random(0,3), math.random(0,3), math.random(0,3))
  110.  
  111. item.Parent = chunk
  112. end
  113.  
  114. local spawnKit = function(name, chunk)
  115. for _, v in pairs (kits[name]) do
  116. spawnItem(v, chunk)
  117. end
  118. end
  119.  
  120. runCommand = function(name, chunk)
  121. if kits[name] ~= nil then
  122. spawnKit(name, chunk)
  123. elseif name == "delete_gui" then
  124. spawner:Destroy()
  125. script:Destroy()
  126. else
  127. spawnItem(name, chunk)
  128. end
  129. end
  130.  
  131. textBox.Changed:connect(function(Text)
  132. local itemsSearch = search(textBox.Text)
  133. if textBox.Text == "" or textBox.Text == " " or textBox.Text == "Put Item Name" or itemsSearch[1] == nil then return end
  134.  
  135. searchScrollFrame:ClearAllChildren()
  136. for i, v in pairs (itemsSearch) do
  137. print (v)
  138. local yPos = ((20 * i) - 20)
  139. local s = Instance.new('TextButton', searchScrollFrame)
  140. s.BorderSizePixel = 0
  141. s.TextScaled = true
  142. s.Text = v
  143. s.Name = v
  144. s.BackgroundColor3 = Color3.fromRGB(120,120,120)
  145. s.BackgroundTransparency = 0.5
  146. s.TextColor3 = Color3.fromRGB(255, 255, 255)
  147. s.Size = UDim2.new(1, 0, 0, 20)
  148. s.Position = UDim2.new(0, 0, 0, yPos)
  149. searchScrollFrame.CanvasSize = UDim2.new(0, 0, 0, 20 * i)
  150.  
  151. s.MouseButton1Click:connect(function()
  152. spawnItem(s.Text, getChunk())
  153. end)
  154. end
  155. textBox.Text = textBox.Text:upper()
  156. textLabel.Text = itemsSearch[1]:upper()
  157. end)
  158.  
  159. spawnButton.MouseButton1Click:connect(function()
  160. if textBox.Text ~= "" or textBox.Text ~= " " and itemToSpawn ~= nil then
  161. local chunk = getChunk()
  162. runCommand(itemToSpawn, chunk)
  163. itemToSpawn = nil
  164. end
  165. end)
  166.  
  167. textBox.FocusLost:connect(function(enter)
  168. if enter then
  169. if textBox.Text ~= "" or textBox.Text ~= " " then
  170. local chunk = getChunk()
  171. runCommand(itemToSpawn, chunk)
  172. itemToSpawn = nil
  173. end
  174. else
  175. searchScrollFrame:ClearAllChildren()
  176. searchScrollFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
  177. textLabel.Text = "Put Item Name"
  178. textBox.Text = "Put Item Name"
  179. end
  180. searchScrollFrame:ClearAllChildren()
  181. searchScrollFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
  182. textLabel.Text = "Put Item Name"
  183. textBox.Text = "Put Item Name"
  184. end)
Add Comment
Please, Sign In to add comment