How do I do proper splash damage?

This is a program that is supposed do splash damage to everyone touching the part every .25 seconds except for the player the script is in. It doesn’t work, how do I fix it?

part = game.Workspace.part
i = 0
while i <= 2.5 do
    local victims = {script.Parent}
    local enabletouchinterest = part.Touched:Connect(function()end)    
    for _, object in ipairs(part:GetTouchingParts()) do
        if object.Parent:FindFirstChild("Humanoid") then
            for _, damaged in ipairs(victims) do
                if object.Parent ~= damaged then
                    table.insert(victims,#victims+1,object.Parent)
                    object.Parent.Humanoid.Health = object.Parent.Humanoid.Health - 10
                end
            end
        end
    end
    enabletouchinterest:Disconnect()
    wait(.25)
    i = i+.25
end
1 Like

The best way to do splash damage would be to do a simple distance check, rather than checking for touching parts.

I am pretty new what do you mean?

A distance check he mentions is like getting a distance between a part and another part, here’s an example.

If a part was 50 studs away from another part, if you print the distance they are away, it would be 50.

In this case if you use distance and if they’re closer than 10 studs, they would take more damage, since the touched event is more faulty and buggy, it’s advised to use distance and some raycast (to avoid damaging the player through a wall).