Pcall() method returns nil

I wrote the code, and an error occurred at the point where the error message was output, saying there was a nil value, but when I looked, the pcall() function didn’t output anything. It just output nil, not true or false. What’s strange is that when I remove the external function, it returns a value. This is a module script. Example code:

local Success, ErrorMessage = nil

local function Function()
     Success, ErrorMessage = pcall(function()
        -- Code here
     end)
   if not Success then
      print(ErrorMessage) -- Error: Attempt to concatenate string with nil
   end
end
1 Like

I don’t recommend pcall function inside another function, i actually did this error before, and it didn’t work to be honest, instead, put the pcall when you CALL the function

2 Likes

Okay, I’ll try that. Thank you for replying.

1 Like

No problem, :smiley:

charsss aaaa

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.