I have a function where I call a hook and get someones money amount from an sql database. The problem is the delay that the information has.
Here is my code:
https://i.gyazo.com/e53245347f49c1fa71ea04db896b3d77.png
If I run it like this, the hook.Add runs after actually returning the amount, so the amount returned is nil.
Not sure what to do. Anyone got any tips?
Unless you implement some kind of task system using coroutines this kind of code isn't possible. You'll have to continue callback chains or use something like promises.
Nvm, found the solution (ish)
Set the amount to a table, as to make the amount.value a reference. Just do a timer check in whatever you need to do to see when it's not nil.
Still want to try and figure out how to be able to make it wait to return a value.
Sorry, you need to Log In to post a reply to this thread.