For example:
thing = false function okay() wait(2) if thing == false then print ("Hello World!") thing = true return okay() elseif thing == true then print("Goodbye!") end end
If it works correctly, it should print hello world, and then goodbye.
return
"returns" a value of a function. For example:
local function returnOne() return 1 end
The function above will return 1. Example:
print(returnOne()) --> 1 print(returnOne()+10)-->11
However functions are useful because you can give them arguments, and you can return different things based on the arguments.
local function evenNumberCheck(num) return num%2==0 end
The above function will check if numbers are even, and return a bool based on that. Example:
print(evenNumberCheck(1)) --> false print(evenNumberCheck(6)) --> true if(evenNumberCheck(8*2))then print("8*2 makes an even number") else print("8*2 doesn't make an even number") end
For more info, I suggest reading this answer to the same question.
You would use return to get the value of a function.
local a = true local b = true function ReturnValues() return a and b end function PrintValues() print(tostring(ReturnValues())) --tostring converts things to strings end PrintValues()