If statment gives me an error when I check if avatar is vaild

I want to check if the avatar is vaild, without an error. When ever I do the code it gives me an error. " Players:GetUserIdFromNameAsync() failed: Unknown user "


if game.Players:GetUserIdFromNameAsync(script.NameA.Value) then
	local id = game.Players:GetUserIdFromNameAsync(script.NameA.Value)
					s.Humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(id))
end```

I figured it out. I just had to put the avatar statment in a pcall

local success, errorMessage = pcall(function()
	game.Players:GetUserIdFromNameAsync(script.NameA.Value)
end)
if success == true then
	local id = game.Players:GetUserIdFromNameAsync(script.NameA.Value)
			
					s.Humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(id))
				
				

end
1 Like