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

My Explosion doesnt deal any damage how to fix?

Asked by 3 years ago
function onTouched(hit)
        if hit.Name == "Key" or hit.Name == "Torso"  then
        local e = Instance.new("Explosion")
        e.Parent = game.Workspace
        e.Position = script.Parent.Position
        e.BlastRadius = 3
        e.BlastPressure = 0
        e.BlastDamage = 10
end 
end 

script.Parent.Touched:connect(onTouched)

i thought the blastdamage would work i dont want the destroy joints thing because i dont want insta kill

1 answer

Log in to vote
3
Answered by
appxritixn 2235 Moderation Voter Community Moderator
3 years ago

Using the Explosion.Hit event, you can damage a player if they are hit by the explosion:

explosion.Hit:Connect(function(part,distance)
    local damage = 100 / distance -- replace with desired value
    local partParent = part.Parent

    local humanoid = partParent:FindFirstChild("Humanoid")

    if humanoid then
        humanoid:TakeDamage(damage)
    end
end)
Ad

Answer this question