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

How could i end a function in different places?

Let me explain better, I have a shop script that uses more than one currency. if the player has at least the required amount of one of the currencies, then the item is bought.

Ex. The item costs 5 burgers and 3 kittens, if I have 5 burgers OR 3 kittens, the transaction is made. is there a function in lua that lets you break out of a function?

if currency1.Value > num then
	--subtract item
else
	--break out of function
end

1 answer

✓ Accepted answer

Make the function return

If you need to come out of a function immediately, you can use the return keyword to do it.

The equivalent keyword for escaping loops is break

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