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

Nuke won't cancel detonating after cancelling countdown?

Asked by 3 years ago

I have a script that sets off a nuke, only problem is that it doesn't turn off the nuke but it does the countdown if that makes sense. I just need to know how to cancel the nuke when isOn = false :)

detonate = script.Parent.Parent.Parent.Parent.clicky.ClickDetector
countdown = script.Parent.Parent.Parent.Parent.message.SurfaceGui.TextBox
sound = script.Parent.Parent.Parent.Parent.message.beep
local isOn = false

function on()
    isOn = true
    for i = 10,1,-1 do
        if not isOn then break end
        countdown.Text = i 
        sound:Play()
        wait(1)
    end
    script.Parent.Anchored = true
    script.Parent.Transparency = 1
    wait()
    script.Parent.Atom.Disabled = false 
end
function off()
    isOn = false
    countdown.Text = "clear"
end
function onClicked()

    if isOn == true then off() else on() 
    end
end

script.Parent.Parent.Parent.Parent.clicky.ClickDetector.MouseClick:connect(onClicked)``

Answer this question