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

How to explode the part and make a succesful debounce?

Asked by
Xyternal 247 Moderation Voter
3 years ago

So i have this code here, and what its supposed to do is that if the part is touching this model called car, then every one second it should explode. The thing is, its neither exploding nor waiting for 1 second. Can any one help me plz?

local RESET_SECONDS = 1
local isTouched = false  
if not isTouched then 
    isTouched = true  -
    script.Parent.Touched:Connect(function(obj)
        if obj:IsDescendantOf(workspace.car) then
            local explosion = Instance.new("Explosion")
            explosion.BlastRadius = 1000000


            explosion.Parent = game.Workspace
            explosion.Position = script.Parent.Position
            print('model touched')

        else
            print("couldn't find model")
        end

        wait(55)
    end)
    wait(RESET_SECONDS)
    isTouched = false  

Answer this question