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

How do you make a function stop, even if it's a loop script?

if I were to do something like

local function test() while true do print("testing") wait() end end

what would be a way I could make the function stop? so it doesn't call the function and stops printing

1 answer

Before I answer, it would be helpful to put your code in Lua, instead of typing it out.

So regarding your question, you can use "break" to stop while true do loops. E.g.

local function test()
	while true do
		print("testing")
		break
	end
end

If you have any problems please comment on this post.

2 comments

0

I forgot to add how do you make the function stop from outside the function?

0

Well, it would be the same code as the initial answer. A function will only fire when test() is put on the code, so "break" will stop the "while true do" loop thus the function will finish.

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