$roleNeeded = 'Staff'
$currentUserId = $currentUserId = \Drupal::currentUser()->id(); \\ or use Drupal\Core\Session\AccountProxyInterface; if using DI
$loadUser = \Drupal::entityTypeManager()->getStorage('user')->load($currentUserId);
$loadUser->set('roles',$roleNeeded );
$loadUser->save();