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

How to make this cannon ball script kill players or NPC's?

Asked by 10 years ago

What I mean, is how would I make this do 150 damage when it hits a player or a NPC? Also how to make it have a 2/4 chance of breaking that enemies joints if their MaxHealth is less than 1000?

pellet = script.Parent


function onTouched(hit)
    humanoid = hit.Parent:findFirstChild("Humanoid")
    if humanoid~=nil then
        g = Instance.new("Explosion") 
        g.ExplosionType = Enum.ExplosionType.NoCraters
                g.Parent = game.Workspace 
                g.Position = script.Parent.Position 
                g.BlastRadius = 5
                g.BlastPressure = 1000
                pellet:remove()
           else
                script.Parent.PelletScript2.Disabled = false
                script.Parent.PelletScript:remove() 
    end
end



connection = pellet.Touched:connect(onTouched)

0
If you want it to kill anything, no matter how much health it has, set the damage to `inf`. BizzareBazaar 22 — 4y

1 answer

Log in to vote
0
Answered by 10 years ago

I made it so it does damage, and here is the code:

pellet = script.Parent
damage = 5 -- the damage done.

pellet.Touched:connect(function(hit)
    humanoid = hit.Parent:findFirstChild("Humanoid")
    if humanoid~=nil then
    humanoid:TakeDamage(damage)
        g = Instance.new("Explosion") 
        g.ExplosionType = Enum.ExplosionType.NoCraters
                g.Parent = game.Workspace 
                g.Position = script.Parent.Position 
                g.BlastRadius = 5
                g.BlastPressure = 1000
                pellet:remove()
           else
                script.Parent.PelletScript2.Disabled = false
                script.Parent.PelletScript:remove() 
end
end)
Ad

Answer this question