Advertisement
HowToRoblox

WeaponEquipper

Apr 21st, 2021
9,272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.63 KB | None | 0 0
  1. local weapons = game.ReplicatedStorage:WaitForChild("Weapons")
  2.  
  3. local re = game.ReplicatedStorage:WaitForChild("EquipWeaponRE")
  4.  
  5.  
  6. re.OnServerEvent:Connect(function(plr, gun)
  7.    
  8.     if gun and gun.Parent.Parent == weapons then
  9.        
  10.         local gunType = gun.Parent
  11.  
  12.        
  13.         for i, child in pairs(plr.Backpack:GetChildren()) do
  14.            
  15.             if gunType:FindFirstChild(child.Name) then
  16.                 child:Destroy()
  17.             end
  18.         end
  19.        
  20.         for i, child in pairs(plr.Character:GetChildren()) do
  21.  
  22.             if gunType:FindFirstChild(child.Name) then
  23.                 child:Destroy()
  24.             end
  25.         end
  26.        
  27.        
  28.         local gunClone = gun:Clone()
  29.         gunClone.Parent = plr.Backpack
  30.     end
  31. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement