Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.84 KB | None | 0 0
  1. local hitmeplz = {"Arm1","Arm2","Chest","Face","Leg1","Leg2"}
  2. local player
  3. local tool = script.Parent.Parent
  4. local handle = tool:WaitForChild("Handle")
  5. local hole = tool:WaitForChild("Hole")
  6. local flash = hole.FlashGui
  7. local lastShot = tick()
  8. local equipped = false
  9. local reloading = false
  10.  
  11. local configs = tool:WaitForChild("Configs")
  12. local remotes = tool:WaitForChild("Remotes")
  13.  
  14. local ammo = configs:WaitForChild("Ammo")
  15. local reserveAmmo = configs:WaitForChild("ReserveAmmo")
  16. local magSize = configs:WaitForChild("MagSize")
  17. local damage = configs:WaitForChild("Damage")
  18. local fireRate = configs:WaitForChild("FireRate")
  19. local headMultiplier = configs:WaitForChild("HeadMultiplier")
  20. local range = configs:WaitForChild("Range")
  21. local reloadTime = configs:WaitForChild("ReloadTime")
  22.  
  23. local canShootRemote = remotes:WaitForChild("CanShoot")
  24. local canReloadRemote = remotes:WaitForChild("CanReload")
  25. local reloadRemote = remotes:WaitForChild("Reload")
  26. local hitRemote = remotes:WaitForChild("Hit")
  27. local shootRemote = remotes:WaitForChild("Shoot")
  28. local traceRemote = remotes:WaitForChild("Trace")
  29. local andagain = remotes:WaitForChild("andbackagain")
  30.  
  31. local emptySound = handle:WaitForChild("EmptySound")
  32. local reloadSound = handle:WaitForChild("ReloadSound")
  33. local shootSound = handle:WaitForChild("ShootSound")
  34.  
  35. local function hit(plr, part)
  36.     if not part then return end
  37.  
  38.     local character = player.Character or player.CharacterAdded:Wait()
  39.     local rootPart = character:WaitForChild("HumanoidRootPart")
  40.     flash.Enabled = true
  41.     wait(.1)
  42.     flash.Enabled = false
  43.    
  44.     if rootPart then
  45.         if (rootPart.CFrame.p - part.CFrame.p).magnitude <= range.Value then --//Check range
  46.             local humanoid
  47.  
  48.             if part.Name == "Handle" then
  49.                 humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
  50.             else
  51.                 humanoid = part.Parent:FindFirstChild("Humanoid")
  52.             end
  53.            
  54.             for i,v in pairs(hitmeplz) do
  55.                 if part.Parent.Name == v then
  56.                     humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
  57.                 end
  58.             end
  59.  
  60.             shootSound:Play()
  61.            
  62.             if humanoid and humanoid.Health > 0 then --//Do nothing if humanoid is dead
  63.                 local newDamage = damage.Value
  64.  
  65.                 if part.Name == "Head" then
  66.                     newDamage = newDamage * headMultiplier.Value
  67.                 end
  68.  
  69.                 humanoid:TakeDamage(newDamage)
  70.             end
  71.         end
  72.     end
  73. end
  74.  
  75. local function equip()
  76.     equipped = true
  77.     player = game:GetService("Players"):GetPlayerFromCharacter(tool.Parent)
  78. end
  79.  
  80. local function unequip()
  81.     equipped = false
  82. end
  83.  
  84. hitRemote.OnServerEvent:Connect(hit)
  85. tool.Equipped:Connect(equip)
  86. tool.Unequipped:Connect(unequip)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement