This is a callable function I'm using to get a user's ID. The issue is, when I call it with a valid username, it returns nil.
function getid(name)
local s,e = pcall(function()
local id = game.Players:GetUserIdFromNameAsync(name)
return id
end)
if not s then
warn(e)
end
end

5 comments
pcall() runs the function in a separate thread. That thread is not associated with the function that pcall() is running inside of. What you're getting is getid()'s return value, which is nil. You're not getting pcall's return value.
shut up bashcaster stop stealing my rep nrd >:(
anyways yeah, if you want to get the return value from a pcall, you should instead return "s" instead outside of the pcall.
Since "s" is a boolean, if I return s, it will just return true or false.
At least it doesn't return nil?