Create a roles entity that contains the different roles as data.
Associate the roles to the user so that a user can have multiple roles.
Associate the roles to the tasks so that a task can have 1 role.
Associate the user to the task by selection in a reference selector and select the role via a second reference selector. Make sure the selectable objects source is xpath and constrain the data via the path that includes the user. This way the associated user’s roles are the only ones that can be selected. See https://docs.mendix.com/refguide/reference-selector#xpath-constraints