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

Why does my script run when it's only supposed to run when hit by an Explosion?

Asked by 5 years ago

So when this script runs it's supposed to decrease the value of health then destroy itself only when it's hit by an explosion, but it just does it on it own without being blown up.

local health = script.Parent.Parent.Parent.Health
local debounce = false
local explosion = workspace:FindFirstChild("Explosion")

modelsHit = {}

explosion.Hit:connect(function(part)
if debounce == false then
    debounce = true
end
    part = script.Parent

    if modelsHit[part] then
        return
    end

modelsHit[part] = true

    if modelsHit[part] == true then
    health.Value = health.Value - 10
    wait(3)
    debounce = false
    script.Parent:Destroy()
    end
end)












0
Hit runs every time te explosion explodes User#19524 175 — 5y

Answer this question