It's a little complicated, when I hit the soldiers directly, with the missile, the soldier doesn't die. If I hit around the radius of the soldier(ground, nearby enemies) the soldier dies. I figured that the actual explosion is killing the soldier, not the missile. How can I make it so the explosion(not the missile, that is already correct) ignores soldiers and hits only the target and the other targets in the vicinity?
function blow(hit)
Hit = hit
plr = game.Players:GetPlayerFromCharacter(hit.Parent)
local explosion = Instance.new("Explosion")
explosion.DestroyJointRadiusPercent = 0 -- neck welds won't be destroyed
explosion.BlastRadius = 20
explosion.BlastPressure = 1000
local maxDamage = 100
local explosion = Instance.new("Explosion")
explosion.DestroyJointRadiusPercent = 0 -- neck welds won't be destroyed
explosion.BlastRadius = 20
explosion.BlastPressure = 1000
explosion.Hit:connect(function(hitPart, partDistance)
local humanoid = hitPart.Parent and hitPart.Parent:FindFirstChild("Humanoid")
local plr = game.Players:GetPlayerFromCharacter(hitPart.Parent)
if hit.Parent.ClassName ~= ("Tool") and hit.Parent.Name ~= ("Workspace") and humanoid and hit.Parent.Name ~= ("Soldier") not plr then
swoosh:stop()
local distance_factor = partDistance / explosion.BlastRadius -- get the distance as a value between 0 and 1
distance_factor = 1 - distance_factor
if hit.Parent.ClassName ~= ("Tool") and hit.Parent.Name ~= ("Workspace") and hit.Parent.Name ~= ("Soldier") -- flip the amount, so that lower == closer == more damage
humanoid:TakeDamage(maxDamage*distance_factor)
else
explosion = Instance.new("Explosion")
explosion.DestroyJointRadiusPercent = 0
end -- 0: no damage; 1: max damage
elseif hit.Parent.ClassName ~= ("Tool") and hit.Parent.Name ~= ("Workspace") and plr and plr.TeamColor ~= game.Teams.Enemies.TeamColor then
swoosh:stop()
explosion = Instance.new("Explosion")
explosion.DestroyJointRadiusPercent = 0
end
end)
I think the problem is by where is says "ELSEIF", there are no santax errors either.
function blowUp(obj)
local sound = Instance.new("Sound")
sound.SoundId = "rbxasset://sounds\\Rocket shot.wav"
sound.Parent = obj
sound.Volume = 1
sound:play()
local explosion = Instance.new("Explosion")
explosion.BlastRadius = explosionRadius
explosion.BlastPressure = explosionPressure -- these are really wussy units
local maxDamage = 75 -- maximum possible damage. could also be based off of the Humanoid's MaxHealth
local explosion = Instance.new("Explosion")
explosion.DestroyJointRadiusPercent = 0 -- neck welds won't be destroyed
explosion.BlastRadius = 20
explosion.Hit:connect(function(hitPart, partDistance)
local humanoid = hitPart.Parent and hitPart.Parent:FindFirstChild("Humanoid")
local plr = game.Players:GetPlayerFromCharacter(hitPart.Parent)
if humanoid and humanoid.Parent.Name ~= ("Soldier") and humanoid.Parent.Name ~= ("Guest") and humanoid.Parent.Name ~= ("") and humanoid.Parent.Name ~= ("") and humanoid.Parent.Name ~= (" ") and humanoid.Parent.Name ~= ("Emperor") and humanoid.Parent.Name ~= ("Governor") and not plr then
local distance_factor = partDistance / explosion.BlastRadius -- get the distance as a value between 0 and 1
distance_factor = 1 - distance_factor -- flip the amount, so that lower == closer == more damage
humanoid:TakeDamage(maxDamage*distance_factor) -- 0: no damage; 1: max damage
elseif plr and plr.TeamColor ~= game.Players.LocalPlayer.TeamColor then
local distance_factor = partDistance / explosion.BlastRadius -- get the distance as a value between 0 and 1
distance_factor = 1 - distance_factor -- flip the amount, so that lower == closer == more damage
humanoid:TakeDamage(maxDamage*distance_factor) -- 0: no damage; 1: max damage
end
end)
