BumpyPlayz

EquipTool

Feb 5th, 2020
2,979
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.70 KB | None | 0 0
  1. game.ReplicatedStorage.Remotes.EquipTool.OnServerEvent:Connect(function(player, item)
  2.    
  3.     if player.OwnedItems:FindFirstChild(item) then
  4.         for i, ifthere in ipairs(player.Backpack:GetChildren()) do
  5.             ifthere:Destroy()
  6.         end
  7.         for i, ifthere in pairs(player.Character:GetChildren()) do
  8.             if ifthere:IsA("Tool") then
  9.                 if game.ServerStorage.Tools:FindFirstChild(ifthere.Name) then
  10.                     ifthere:Destroy()
  11.                 end
  12.             end
  13.         end
  14.        
  15.         local clone = game.ServerStorage.Tools:FindFirstChild(item):Clone()
  16.         clone.ItemNumber:Destroy()
  17.         clone.Cost:Destroy()
  18.         clone.Parent  = player.Backpack
  19.         player.Equipped.Value = item
  20.         game.ReplicatedStorage.Remotes.EquipTool:FireClient(player, item)
  21.     end
  22.    
  23. end)
Add Comment
Please, Sign In to add comment