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

Need help with stopping my function, bindable functions?

Asked by
JoneXI 51
4 years ago
Edited 4 years ago

Hello, I have a problem. I have a GUI, you open a window inside the GUI and inside it there is a color cycle thing I made. I used bindable function for that. The script works fine, but once I exit out of it the function doesn't stop running. How do I stop it? I tried to use a second bindable function and it didin't work. I dont get any errors. Thank you.

Script:

local btn1 = script.Parent.btn1
local btn2 = script.Parent.btn2
local btn3 = script.Parent.btn3
local btn4 = script.Parent.btn4
local btn5 = script.Parent.btn5
local btn6 = script.Parent.btn6
local btn7 = script.Parent.btn7
local btn8 = script.Parent.btn8

local btnTable = {btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8}
function cycle()
while true do
for i=1,#btnTable do
    print("Hack happening")
         btnTable[i].BackgroundColor3 = Color3.fromRGB(0, 255, 0)
        wait(1)
        btnTable[i].BackgroundColor3 = Color3.fromRGB(255, 0, 0)    
end
end
end
script.Parent.Parent.Hacking1.OnInvoke = function()
    cycle()
end

Answer this question