01 | local function ReturnSomething() |
02 | return 'Hi' |
03 | end |
04 |
05 |
06 | local S,E = pcall ( function () |
07 | ReturnSomething() |
08 |
09 |
10 | end ) |
11 |
12 | print (S,E) |
this prints (true , nil)
for some reason
I cant get a function to return something to a pcall
I want E to return Hi not nil how do i do this
You need to return it in the actual pcall() callback, instead of in your function.
ie:
1 | local S, E = pcall ( function () |
2 | return "Hi" |
3 | end |
4 | print (S, E) |
true, Hi
1 | local function returnSomething() |
2 | return "Hi" |
3 | end |
4 |
5 | local S, E = pcall ( function () |
6 | return returnSomething() |
7 | end ) |
8 |
9 | print (S, E) |
true, Hi