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

What is a function i can use to break out of a function?

How does one break out of a touch function?

2 comments

0

Try 'return'

0

Make this an answer so i can verify it

1 answer

✓ Accepted answer

to discontinue execution of a function you need to use the return keyword:

for instance:

function sayHello(who)
	if(not who) then
		print"you did not specify a person to say hello to."
		return --terminates further execution!
	end

	print("Hello, ",who,".  how are you?")
end

sayHello("Roblox") --//"Hello, Roblox. How are you"
sayHello()--//"you did not specify a person to say hello to."

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