Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[/////////////////////////////////////////Item Spawner by: Alasdair////////////////////////////////////////////
- Instructions:
- 1.) Type item name or command (You don't have to type whole item name.)
- 2.) Press enter or "Spawn"
- 3.) Try to pick up the spawned item through the inventory gui. By right clicking it and clicking "Pick up"
- 4.) Another item will spawn on the ground for the server. This is the item you can pick up.
- If an item doesn't spawn, drop any item on the ground first.
- Settings:
- ]]
- local kits = {
- ["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"};
- }
- --///////////////////////////////////////DONT EDIT ANYTHING BELOW THIS////////////////////////////////////////////
- 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
- local kitToSpawn = 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(97, 189, 22)
- 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
- for i, v in pairs (kits) do
- print (i)
- if text:upper() == i:sub(1, string.len(text)):upper() then
- table.insert(itemSearch, i)
- end
- end
- itemToSpawn = itemSearch[1]
- return itemSearch
- 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
- local spawnItem = function(name, chunk)
- 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
- end
- spawnKit = function(name, chunk)
- print ('spawn kit function running')
- for _, v in pairs (kits[name]) do
- spawnItem(v, chunk)
- end
- end
- runCommand = function(name, chunk)
- if kits[name] ~= nil then
- spawnKit(name, chunk)
- elseif name == "delete_gui" then
- spawner:Destroy()
- script:Destroy()
- else
- spawnItem(name, chunk)
- 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:ClearAllChildren()
- for i, v in pairs (itemsSearch) do
- print (v)
- local yPos = ((20 * i) - 20)
- local s = Instance.new('TextLabel', 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)
- searchScrollFrame.CanvasSize = UDim2.new(0, 0, 0, 20 * i)
- end
- textBox.Text = textBox.Text:upper()
- textLabel.Text = itemsSearch[1]:upper()
- end)
- spawnButton.MouseButton1Click:connect(function()
- if textBox.Text ~= "" or textBox.Text ~= " " and itemToSpawn ~= nil then
- local chunk = getChunk()
- runCommand(itemToSpawn, chunk)
- itemToSpawn = nil
- end
- end)
- textBox.FocusLost:connect(function(enter)
- if enter then
- if textBox.Text ~= "" or textBox.Text ~= " " then
- local chunk = getChunk()
- runCommand(itemToSpawn, chunk)
- itemToSpawn = nil
- end
- else
- searchScrollFrame:ClearAllChildren()
- searchScrollFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
- textLabel.Text = "Put Item Name"
- textBox.Text = "Put Item Name"
- end
- searchScrollFrame:ClearAllChildren()
- searchScrollFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
- textLabel.Text = "Put Item Name"
- textBox.Text = "Put Item Name"
- end)
Advertisement
Advertisement