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

My explosion damage script doesn't deal damage to humanoids?

Asked by
lucas4114 607 Moderation Voter
9 years ago

The explosion doesn't deal damge, how do I fix it? Explosion, Bullet and Damage do have a value so it isn't the problem.

local CheckedForKill = false
        Explosion.Hit:connect(function(PartHit, hitDistance)
            if CheckedForKill == false then
                CheckedForKill = true
                local humanoid = PartHit.Parent:FindFirstChild("Humanoid")
                if humanoid and not PartHit.Name == "Bullet" then
                    if hitDistance <= ExplosionRange then
                        humanoid:TakeDamage(Damage)
                        wait(0.05)
                        if humanoid.Health == 0 or humanoid.Health <= 0 then
                            local player = game.Players:GetPlayerFromCharacter(user)
                            player.leaderstats.Kills.Value = player.leaderstats.Kills.Value + 1
                        end
                    end
                end
            end
        end)

And here's an example of what happens: https://gyazo.com/8ef8a1f0297641994130a298049330af

0
Shouldn't hitDistance be greater than or equal to ExplosionRange? if hitDistance >= ExplosionRange then DeveloperSolo 370 — 9y
0
@JohnTUnderwood No, I want the player to be damaged if they're in the rage of the explosion not out of it... lucas4114 607 — 9y

Answer this question