pizzaloiopo

!apocalypse-rising-2

Jun 29th, 2018
3,686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.09 KB | None | 0 0
  1. local spawner = Instance.new ("ScreenGui")
  2. local searchScrollFrame = Instance.new ("ScrollingFrame")
  3. local textBox = Instance.new ("TextBox")
  4. local textLabel = Instance.new("TextLabel")
  5. local spawnButton = Instance.new ("TextButton")
  6.  
  7. local client = game.Players.LocalPlayer
  8.  
  9. local itemToSpawn = nil
  10.  
  11. spawner.Parent = game.Players.LocalPlayer.PlayerGui
  12.  
  13. searchScrollFrame.Size = UDim2.new (0, 250, 0, 100)
  14. searchScrollFrame.Position = UDim2.new (0.02, 0, 0.9, -105)
  15. searchScrollFrame.BackgroundTransparency = 1
  16. searchScrollFrame.Parent = spawner
  17.  
  18. textBox.Size = UDim2.new (0, 250, 0, 25)
  19. textBox.Position = UDim2.new (.02, 0, .9, 0)
  20. textBox.BackgroundColor3 = Color3.fromRGB(120,120,120)
  21. textBox.TextColor3 = Color3.fromRGB(255,255,255)
  22. textBox.BorderSizePixel = 0
  23. textBox.BackgroundTransparency = 0.5
  24. textBox.Text = "Put Item Name"
  25. textBox.TextXAlignment = Enum.TextXAlignment.Left
  26. textBox.Parent = spawner
  27.  
  28. textLabel.Size = UDim2.new (1, 0, 1, 0)
  29. textLabel.Position = UDim2.new (0, 0, 0, 0)
  30. textLabel.BackgroundTransparency = 1
  31. textLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
  32. textLabel.Text = "Put Item Name"
  33. textLabel.TextXAlignment = Enum.TextXAlignment.Left
  34. textLabel.Parent = textBox
  35.  
  36. spawnButton.Size = UDim2.new (0, 250, 0, 20)
  37. spawnButton.Position = UDim2.new (.02, 0, .9, 25)
  38. spawnButton.BackgroundColor3 = Color3.fromRGB(50, 158, 220)
  39. spawnButton.TextColor3 = Color3.fromRGB(255,255,255)
  40. spawnButton.BorderSizePixel = 0
  41. spawnButton.BackgroundTransparency = 0
  42. spawnButton.Text = ("Spawn")
  43. spawnButton.Parent = spawner
  44.  
  45. allLoot = {"delete_gui"}
  46.  
  47. for _, item in pairs (game.ReplicatedStorage.Assets.Loot:GetDescendants()) do
  48. if item:IsA("Model") then
  49. print (item)
  50. table.insert(allLoot, item.Name)
  51. end
  52. end
  53.  
  54. local search = function(text)
  55. local itemSearch = {}
  56. for i, v in pairs (allLoot) do
  57. if text:upper() == v:sub(1, string.len(text)):upper() then
  58. table.insert(itemSearch, v)
  59. end
  60. end
  61. return itemSearch
  62. end
  63.  
  64. local spawnItem = function(name, chunk)
  65. if textBox.Text == "delete_gui" then
  66. spawner:Destroy()
  67. script:Destroy()
  68. return
  69. end
  70.  
  71.  
  72. local item = Instance.new ("CFrameValue")
  73. item.Name = name
  74. item.Value = game.Workspace.Characters[client.Name].Head.CFrame * CFrame.new (math.random(0,3), math.random(0,3), math.random(0,3))
  75.  
  76. item.Parent = chunk
  77.  
  78. textLabel.Text = "Put Item Name"
  79. textBox.Text = "Put Item Name"
  80. end
  81.  
  82. local getChunk = function()
  83. local lootFolder = game.Workspace.Loot.Nodes
  84. for _, v in pairs (lootFolder:GetDescendants()) do
  85. if v:IsA("Model") then
  86. return v.Parent.Parent
  87. end
  88. end
  89. end
  90.  
  91. textBox.Changed:connect(function(Text)
  92. local itemsSearch = search(textBox.Text)
  93. if textBox.Text == "" or textBox.Text == " " or textBox.Text == "Put Item Name" or itemsSearch[1] == nil then return end
  94.  
  95. searchScrollFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
  96. searchScrollFrame:ClearAllChildren()
  97. for i, v in pairs (itemsSearch) do
  98. print (v)
  99. local yPos = ((20 * i) - 20)
  100. local s = Instance.new('TextButton', searchScrollFrame)
  101. s.BorderSizePixel = 0
  102. s.TextScaled = true
  103. s.Text = v
  104. s.Name = v
  105. s.BackgroundColor3 = Color3.fromRGB(120,120,120)
  106. s.BackgroundTransparency = 0.5
  107. s.TextColor3 = Color3.fromRGB(255, 255, 255)
  108. s.Size = UDim2.new(1, 0, 0, 20)
  109. s.Position = UDim2.new(0, 0, 0, yPos)
  110. end
  111. textBox.Text = textBox.Text:lower()
  112. textLabel.Text = itemsSearch[1]:lower()
  113. itemToSpawn = itemsSearch[1]
  114. end)
  115.  
  116. spawnButton.MouseButton1Click:connect(function()
  117. if textBox.Text ~= "" or textBox.Text ~= " " and itemToSpawn ~= nil then
  118. local chunk = getChunk()
  119. spawnItem(itemToSpawn, chunk)
  120. itemToSpawn = nil
  121. end
  122. end)
  123.  
  124. textBox.FocusLost:connect(function(enter)
  125. if enter then
  126. if textBox.Text ~= "" or textBox.Text ~= " " then
  127. local chunk = getChunk()
  128. spawnItem(itemToSpawn, chunk)
  129. itemToSpawn = nil
  130. end
  131. end
  132. end)
Advertisement
Add Comment
Please, Sign In to add comment