Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local lib = {}
- local function round(num, idp)
- local mult = 10^(idp or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- function lib.Explosion(position, isVisual, maxRadius, killRadius, ignoreForcefields, ignoreTeamColors)
- --[[
- bool position = Position of the explosion
- bool isVisual = Show the explosion effect
- number maxRadius = Damage radius of the explosion
- number killRadius = Guaranteed kill radius of the explosion
- bool ignoreForcefields = Does the explosion damage ignore forcefields
- OPTIONAL: table ignoreTeamColors = Table of team colors to ignore damage
- ]]
- local ex = Instance.new("Explosion", workspace)
- ex.BlastRadius = maxRadius
- ex.Position = position
- ex.BlastPressure = 0
- for _, player in pairs(game.Players:GetPlayers()) do
- if player.Character ~= nil then
- if player.Character:findFirstChild("Torso") then
- local teamColor = player.TeamColor
- local ignoreDamage = false
- if ignoreTeamColors ~= nil then
- ignoreDamage = true
- for _, tc in pairs(ignoreTeamColors) do
- if tc == teamColor then
- ignoreDamage = false
- break
- end
- end
- end
- if not ignoreDamage then
- local dist = (player.Character.Torso.Position - position).magnitude
- if not (dist >= maxRadius) then
- local mult = ((maxRadius - killRadius) / 100)
- local dmg = (maxRadius - dist) / mult
- dmg = round(dmg)
- if ignoreForcefields then
- player.Character.Humanoid.Health = player.Character.Humanoid.Health - dmg
- else
- player.Character.Humanoid:TakeDamage(dmg)
- end
- end
- end
- end
- end
- end
- end
- return lib
Add Comment
Please, Sign In to add comment