What method(s) do I use to make a function wait until another function has finished?
Scripts are pretty linear. There's not often that you need to do something like this because a function will automatically wait for that function to finish until it continues. There is one way to do this, though, if needed.
local FuncDone = false function f1() FuncDone = false -- Reset it in case of multiple calls Spawn(function() -- Start a new thread print("A") wait(3) print("B") FuncDone = true end) end function f2() f1() repeat wait(1/20) until FuncDone print("C") end f2()
You could have a function that returns true or false, and then have a repeat statement.
So for example:
function f1() if 1==1 then return true else return false end end function f2() f1() repeat wait() until f1 end