Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I Get killed from my own blast??

Asked by 5 years ago
Edited 5 years ago

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)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

(Sorry if I am wrong I am new to scripting attacks ect)) This might be because you are making its CFrame at the tools handle. So it collides with either you or the tool setting it off before it can move. I would re write it with something like I did for the CFrame part.

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 * CFrame.new(0,0,-5) -- now for my attacks in my scripts I do something like that.
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)
0
thank you so much SplendidKyle567 8 — 5y
0
Yw, happytimeroblox101 36 — 5y
Ad

Answer this question