Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I end a loop using a ClickDetector button?

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

while whatever do
	--do your loop code
	if clickdetector.mouseclick then
		break
	else
		continue
	end
end

1 comment

0

or any other loop, the break part is what you want

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

This discussion is preserved as it was. New answers, comments, and votes are closed.