So i was creating a projectile ball thing that shoots out of a tool. I tried to make it so whenever it touched anything it would explode. When i shoot it however, it kills me. I tried to add or multiply the position of the projectile from the tool but it still didnt work. Is there any way to make the me immune to the explosion itself? The script it long, so srry about that.
local Tool = script.Parent
Tool.RemoteEvent.OnServerEvent:Connect(function(Player, CoolDown)
local Character = Player.Character
local hum = Character.Humanoid
CoolDown = true
local Blast = Instance.new("Part")
Blast.BrickColor = BrickColor.new("Really red")
Blast.Material = "Neon"
Blast.Transparency = 0.25
Blast.Anchored = false
Blast.CanCollide = false
Blast.Shape = Enum.PartType.Ball
Blast.Locked = true
Blast.Size = Vector3.new(3,3,3)
Blast.Position = Tool.Handle.Position
Blast.CFrame = Tool.Handle.CFrame
Blast.Parent = Character
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.Velocity = Character.HumanoidRootPart.CFrame.lookVector * 100
bv.Parent = Blast
local damagefortheBlast = true
Blast.Touched:Connect(function(hit)
if not damagefortheBlast then return end
damagefortheBlast = false
local ehum = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid")
if ehum and ehum ~= hum then
ehum:TakeDamage(10)
end
wait()
damagefortheBlast = true
for i = 1,10 do
local Explosion = Instance.new("Explosion", game.Workspace)
Explosion.BlastPressure = 5000
Explosion.BlastRadius = 4
Explosion.ExplosionType = Enum.ExplosionType.CratersAndDebris
Explosion.DestroyJointRadiusPercent = 1
Explosion.Position = Blast.Position
Explosion.Parent = workspace
Explosion.Visible = true
local damagefortheExplosion = true
Explosion.Hit:Connect(function(hit)
if not damagefortheExplosion then return end
damagefortheExplosion= false
local ehum = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid")
if ehum and ehum ~= hum then
ehum:TakeDamage(10)
end
wait()
damagefortheExplosion = false
end)
end
end)
end)

2 comments
thank you so much
Yw,