Explosion.Neutral and Explosion.TeamColor

There’s no way to make a non-teamkilling explosion. There should be.

Explosion.Hit sure seems like a way, even if it does take a marginal amount of effort to script.

I’ve never used explosions before. Do they have to damage players? If not, a custom damage script isn’t hard.

But anyhow, this would be great to have.

Set the explosion’s DestroyJointRadiusPercent or something to 0 or set the BlastPressure to 0 and then use Explosion.Hit

BlastRadius of 0 and your own code to handle damage

EDIT: Or BlastPressure. I dont remember which one decides the size of the visible explosion

What everyone else said.

What we also need is explosion.Color.

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
1 Like

Ethan is smart enough to figure this stuff out. I think he just wants an easy way to do it.

I’m really just wanting this for gear. I could add it to the module library I’m using but I don’t think that new players who are reading the scripts to learn lua are going to understand what’s going on.

It would be useful if you want explosions to blow everything apart excluding your team members…

1 Like

Everyone seems to be fixated on an idea that because it can be done means that we don’t need an easier way to do it.

Those people need to not.

[quote] Everyone seems to be fixated on an idea that because it can be done means that we don’t need an easier way to do it.

Those people need to not. [/quote]

A million thanks :blush:

[quote] Everyone seems to be fixated on an idea that because it can be done means that we don’t need an easier way to do it.

Those people need to not. [/quote]

There’s also always the question of whether we would want the staff to work on implementing an easier method to do something we can, or implementing brand new features.

Though that’s the decision of the staff anyhow, so there’s nothing really for either side to argue. :stuck_out_tongue:

Instead of having two properties, it would make much more sense to have [tt]Explosion.Creator[/tt] which would refer to the humanoid/player who created the explosion.

Then add [tt]Teams.AllowTeamKilling[/tt] like I proposed months ago, and the game engine itself could determine whether or not it should kill. This is a much better way of doing things, because then the place creator can decide whether or not he wants to allow teamkilling without modifying every gear in the place.

Edit: There could also be a property like [tt]Teams.ExplosionsCanTeamKill[/tt] if necessary

See Documentation - Roblox Creator Hub

3 Likes