Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

In which cases would pcalls second parameter return nil even if the first one returned true?

Asked by 4 years ago

So I have a script

local S,E = pcall(function()
    return DataStore:GetAsync(Player.UserId)
end)

if S then
    if E then



    end
end

-- Which situations would cause E to return nil even if the pcall's first parameter was true 

I know one way which is when GetAsync() returns nothing

But I was wondering if there was any other way E would return nil even if first parameter returned true

1 answer

Log in to vote
0
Answered by 4 years ago
Edited by royaltoe 4 years ago

The first return value is whether it ran without error. If there was is no error, it will be true otherwise it will be false.

The second return value is going to be nil if it ran without error (first is true) or be an error message depending on if one was given (as far as I know all errors with the language itself provide an error message, but calling error with no provided message of course won't give one).

Ad

Answer this question