Pardon my knowledge, but I’m quite bad with pcalls. If I wrap something in pcall, how would I return that the code errored to the client. I’m not sure if I’m doing it correctly?
local id
local success, errormessage = pcall(function()
id = game.Players:GetUserIdFromNameAsync(Input) -- Input is a text
end)
The thing is if input is wrong, or nil then it gives me an error. Is that how pcall’s are meant to work or what? I’m trying to send a remote event to the client to say your input is invalid, but the error doesn’t allow me.
local id
local HadSuccess, Returned = pcall(function()
id = game.Players:GetUserIdFromNameAsync(Input)
if id then
return true -- Valid
else
return false -- Invalid
end
end)
if HadSuccess and Returned then
print(Returned)
end
Well I used your code but the pcall isn’t working or something isn’t. If the player’s id doesn’t exist it would error. In the pcall, where it says invalid, I sent a remote event back to the client but it doesn’t even work.
Yeah, everything’s working as expected now. Thanks Incapaz and others!
I have one last question if anyone’s willing to answer. The remote function returns if it’s successful but how would I hook up something to change on the client. For example, if it’s successful the gui textbox background would change to green and vice verca?