Guest User

asdasdadsasdads

a guest
Feb 16th, 2015
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.71 KB | None | 0 0
  1. local lib = {}
  2.  
  3.  
  4. local function round(num, idp)
  5.     local mult = 10^(idp or 0)
  6.     return math.floor(num * mult + 0.5) / mult
  7. end
  8.  
  9.  
  10. function lib.Explosion(position, isVisual, maxRadius, killRadius, ignoreForcefields, ignoreTeamColors)
  11.     --[[
  12.         bool position                     = Position of the explosion
  13.         bool isVisual                     = Show the explosion effect
  14.         number maxRadius                  = Damage radius of the explosion
  15.         number killRadius                 = Guaranteed kill radius of the explosion
  16.         bool ignoreForcefields            = Does the explosion damage ignore forcefields
  17.         OPTIONAL: table ignoreTeamColors  = Table of team colors to ignore damage
  18.     ]]
  19.     local ex = Instance.new("Explosion", workspace)
  20.     ex.BlastRadius = maxRadius
  21.     ex.Position = position
  22.     ex.BlastPressure = 0
  23.    
  24.     for _, player in pairs(game.Players:GetPlayers()) do
  25.         if player.Character ~= nil then
  26.             if player.Character:findFirstChild("Torso") then
  27.                 local teamColor = player.TeamColor
  28.                 local ignoreDamage = false
  29.                 if ignoreTeamColors ~= nil then
  30.                     ignoreDamage = true
  31.                     for _, tc in pairs(ignoreTeamColors) do
  32.                         if tc == teamColor then
  33.                             ignoreDamage = false
  34.                             break
  35.                         end
  36.                     end
  37.                 end
  38.                 if not ignoreDamage then
  39.                     local dist = (player.Character.Torso.Position - position).magnitude
  40.                     if not (dist >= maxRadius) then
  41.                         local mult = ((maxRadius - killRadius) / 100)
  42.                         local dmg = (maxRadius - dist) / mult
  43.                         dmg = round(dmg)
  44.                         if ignoreForcefields then
  45.                             player.Character.Humanoid.Health = player.Character.Humanoid.Health - dmg
  46.                         else
  47.                             player.Character.Humanoid:TakeDamage(dmg)
  48.                         end
  49.                     end
  50.                 end
  51.             end
  52.         end
  53.     end
  54. end
  55.  
  56.  
  57. return lib
Add Comment
Please, Sign In to add comment