Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local spawner = Instance.new ("ScreenGui")
- local searchScrollFrame = Instance.new ("ScrollingFrame")
- local textBox = Instance.new ("TextBox")
- local textLabel = Instance.new("TextLabel")
- local spawnButton = Instance.new ("TextButton")
- local client = game.Players.LocalPlayer
- local itemToSpawn = nil
- spawner.Parent = game.Players.LocalPlayer.PlayerGui
- searchScrollFrame.Size = UDim2.new (0, 250, 0, 100)
- searchScrollFrame.Position = UDim2.new (0.02, 0, 0.9, -105)
- searchScrollFrame.BackgroundTransparency = 1
- searchScrollFrame.Parent = spawner
- textBox.Size = UDim2.new (0, 250, 0, 25)
- textBox.Position = UDim2.new (.02, 0, .9, 0)
- textBox.BackgroundColor3 = Color3.fromRGB(120,120,120)
- textBox.TextColor3 = Color3.fromRGB(255,255,255)
- textBox.BorderSizePixel = 0
- textBox.BackgroundTransparency = 0.5
- textBox.Text = "Put Item Name"
- textBox.TextXAlignment = Enum.TextXAlignment.Left
- textBox.Parent = spawner
- textLabel.Size = UDim2.new (1, 0, 1, 0)
- textLabel.Position = UDim2.new (0, 0, 0, 0)
- textLabel.BackgroundTransparency = 1
- textLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
- textLabel.Text = "Put Item Name"
- textLabel.TextXAlignment = Enum.TextXAlignment.Left
- textLabel.Parent = textBox
- spawnButton.Size = UDim2.new (0, 250, 0, 20)
- spawnButton.Position = UDim2.new (.02, 0, .9, 25)
- spawnButton.BackgroundColor3 = Color3.fromRGB(50, 158, 220)
- spawnButton.TextColor3 = Color3.fromRGB(255,255,255)
- spawnButton.BorderSizePixel = 0
- spawnButton.BackgroundTransparency = 0
- spawnButton.Text = ("Spawn")
- spawnButton.Parent = spawner
- allLoot = {"delete_gui"}
- for _, item in pairs (game.ReplicatedStorage.Assets.Loot:GetDescendants()) do
- if item:IsA("Model") then
- print (item)
- table.insert(allLoot, item.Name)
- end
- end
- local search = function(text)
- local itemSearch = {}
- for i, v in pairs (allLoot) do
- if text:upper() == v:sub(1, string.len(text)):upper() then
- table.insert(itemSearch, v)
- end
- end
- return itemSearch
- end
- local spawnItem = function(name, chunk)
- if textBox.Text == "delete_gui" then
- spawner:Destroy()
- script:Destroy()
- return
- end
- local item = Instance.new ("CFrameValue")
- item.Name = name
- item.Value = game.Workspace.Characters[client.Name].Head.CFrame * CFrame.new (math.random(0,3), math.random(0,3), math.random(0,3))
- item.Parent = chunk
- textLabel.Text = "Put Item Name"
- textBox.Text = "Put Item Name"
- end
- local getChunk = function()
- local lootFolder = game.Workspace.Loot.Nodes
- for _, v in pairs (lootFolder:GetDescendants()) do
- if v:IsA("Model") then
- return v.Parent.Parent
- end
- end
- end
- textBox.Changed:connect(function(Text)
- local itemsSearch = search(textBox.Text)
- if textBox.Text == "" or textBox.Text == " " or textBox.Text == "Put Item Name" or itemsSearch[1] == nil then return end
- searchScrollFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
- searchScrollFrame:ClearAllChildren()
- for i, v in pairs (itemsSearch) do
- print (v)
- local yPos = ((20 * i) - 20)
- local s = Instance.new('TextButton', searchScrollFrame)
- s.BorderSizePixel = 0
- s.TextScaled = true
- s.Text = v
- s.Name = v
- s.BackgroundColor3 = Color3.fromRGB(120,120,120)
- s.BackgroundTransparency = 0.5
- s.TextColor3 = Color3.fromRGB(255, 255, 255)
- s.Size = UDim2.new(1, 0, 0, 20)
- s.Position = UDim2.new(0, 0, 0, yPos)
- end
- textBox.Text = textBox.Text:lower()
- textLabel.Text = itemsSearch[1]:lower()
- itemToSpawn = itemsSearch[1]
- end)
- spawnButton.MouseButton1Click:connect(function()
- if textBox.Text ~= "" or textBox.Text ~= " " and itemToSpawn ~= nil then
- local chunk = getChunk()
- spawnItem(itemToSpawn, chunk)
- itemToSpawn = nil
- end
- end)
- textBox.FocusLost:connect(function(enter)
- if enter then
- if textBox.Text ~= "" or textBox.Text ~= " " then
- local chunk = getChunk()
- spawnItem(itemToSpawn, chunk)
- itemToSpawn = nil
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment