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

How can I end a loop using a ClickDetector button?

Asked by 4 years ago

I would like to be able to end a while true loop by using a ClickDetector button but I am unsure how. Any help would be appreciated.

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago
while whatever do
    --do your loop code
    if clickdetector.mouseclick then
        break
    else
        continue
    end
end
0
or any other loop, the break part is what you want matiss112233 258 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

matiss is correct, but it is a bit off. This is more how it should be.

while condition do
    --loop code
    ClickDetector.MouseClick:Connect(function()
        break
    end)
end

Answer this question