Try to use pcalls instead, let me know how this code works for you:
local success, userId = pcall(function() return game.Players:GetUserIdFromNameAsync(Username); end);
if success and userId then
local success2, userInfo = pcall(function() return game.UserService:GetUserInfosByUserIdsAsync({userId}); end);
if success2 and userInfo and #userInfo > 0 then
print("Player's display name:", userInfo[1].DisplayName);
else
warn("Failed to get userid");
end;
else
warn("Failed to get userid");
end;