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

How to make this create an explosion?

Asked by 10 years ago

Whatever the paintball hits, it creates an explosion that does 25-1000 damage depending on if it's a direct hit or splash damage. Anyone help? By the way, blast pressure is 0, and blast radius I will determine.

ball = script.Parent
damage = 25



function onTouched(hit)
    local humanoid = hit.Parent:findFirstChild("Zombie")



    if humanoid ~= nil then
        tagHumanoid(humanoid)
        humanoid.Health = humanoid.Health - damage
        wait(2)
        untagHumanoid(humanoid)
    end

    connection:disconnect()
    ball.Parent = nil
end

function tagHumanoid(humanoid)
    -- todo: make tag expire
    local tag = ball:findFirstChild("creator")
    if tag ~= nil then
        local new_tag = tag:clone()
        new_tag.Parent = humanoid
    end
end


function untagHumanoid(humanoid)
    if humanoid ~= nil then
        local tag = humanoid:findFirstChild("creator")
        if tag ~= nil then
            tag.Parent = nil
        end
    end
end

connection = ball.Touched:connect(onTouched)

wait(0.8)
ball.Parent = nil

2 answers

Log in to vote
0
Answered by 10 years ago

Go to this link: Explosion Damage. It will give you everything you need. Hope this helped!

Ad
Log in to vote
0
Answered by
dyler3 1510 Moderation Voter
10 years ago

Well this would be how to create the explosion. I'm kinda lost on how to make the damage part.

ball = script.Parent
damage = 25



function onTouched(hit)
    local humanoid = hit.Parent:findFirstChild("Zombie")
    E=Instance.new("Explosion",game.Workspace)
    E.Position=humanoid.Position
    E.BlastPressure=0
    E.BlastRadius= --Enter what you want here.

    if humanoid ~= nil then
        tagHumanoid(humanoid)
        humanoid.Health = humanoid.Health - damage
        wait(2)
        untagHumanoid(humanoid)
    end

    connection:disconnect()
    ball.Parent = nil
end

function tagHumanoid(humanoid)
    -- todo: make tag expire
    local tag = ball:findFirstChild("creator")
    if tag ~= nil then
        local new_tag = tag:clone()
        new_tag.Parent = humanoid
    end
end


function untagHumanoid(humanoid)
    if humanoid ~= nil then
        local tag = humanoid:findFirstChild("creator")
        if tag ~= nil then
            tag.Parent = nil
        end
    end
end

connection = ball.Touched:connect(onTouched)

wait(0.8)
ball.Parent = nil

Answer this question