Advertisement
Er1x_Official

Tool/Item Dropper Script Revamped Roblox

Jul 1st, 2021
1,620
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.57 KB | None | 0 0
  1. -- variables (Made By Er_1x / ERIC#2073)
  2. local hum = script.Parent -- humanoid
  3. local tfolder = game:GetService("ReplicatedStorage"):FindFirstChild("Items") -- finds the folder
  4. local folderc = tfolder:GetChildren() -- gets the items on the folder
  5.  
  6. local IsModel = false -- check for model if its not a model leave it to false else set it to true
  7. local IsRandom = true -- if set to false add a tool name to get the specific iten you want
  8. local IsTool = true -- checks if its a tool or not IF IT IS A TOOL set it to true if not then flase
  9. local ItemName = "" -- if israndom is set to true leave it blank
  10.  
  11. -- script part
  12. hum.Died:Connect(function() -- function
  13.     if IsRandom == true then
  14.         if IsTool == false then
  15.             local random = math.random(1, #folderc) -- randomizes
  16.             local index = folderc[random] -- index the tool
  17.  
  18.             local item = index:Clone() -- clone the randomized tool
  19.             item.Parent = game:GetService("Workspace") -- parent of the tool
  20.  
  21.             if IsModel == true then -- if it is a model or not dont change, only change the one on the variables
  22.                 item:MoveTo(hum.Parent.Head.Position) -- how we can move it because its a model
  23.             else
  24.                 item.CFrame = hum.Parent.Head.CFrame -- cframe ( position of the tool)
  25.             end
  26.  
  27.             print("Random Item Dropped: "..index.Name) -- notify
  28.         else
  29.             local random = math.random(1, #folderc) -- randomizes
  30.             local index = folderc[random] -- index the item
  31.  
  32.             local tool = index:Clone() -- clone the randomized item
  33.             tool.Parent = game:GetService("Workspace") -- parent of the item
  34.             tool.Handle.CFrame = hum.Parent.Head.CFrame -- cframe ( position of the item)
  35.  
  36.             print("Random Tool Dropped: "..index.Name) -- notify
  37.         end
  38.     else -- if random is not in true
  39.         if IsTool == false then
  40.             local item = tfolder:FindFirstChild(ItemName):Clone() -- gets the tool ( finds the tool inside the folder
  41.             item.Parent = game:GetService("Workspace") -- parent of the tool
  42.  
  43.             if IsModel == true then -- if it is a model or not dont change, only change the one on the variables
  44.                 item:MoveTo(hum.Parent.Head.Position) -- how we can move it because its a model
  45.             else
  46.                 item.CFrame = hum.Parent.Head.CFrame -- cframe ( position of the tool)
  47.             end
  48.  
  49.             print("Item Dropped: "..ItemName) -- notify
  50.         else
  51.             local tool = tfolder:FindFirstChild(ItemName):Clone() -- gets the tool ( finds the tool inside the folder
  52.             tool.Parent = game:GetService("Workspace") -- parent of the tool
  53.             tool.Handle.CFrame = hum.Parent.Head.CFrame -- cframe ( position of the tool)
  54.  
  55.             print("Tool Dropped: "..ItemName) -- notify
  56.         end
  57.     end
  58. end) -- end of function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement