HowToRoblox

WeaponEquipper

Apr 21st, 2021
952
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×