This might not be the best solution, but you could possibly use GroupService:GetGroupsAsync() for this. It uses a userID.
You’d have to loop through every group, check the group id to see if it’s the right group, and then check the role. It’s pretty scuffed, but I don’t know of any other method.
You can only perform the “GetRoleInGroup()” function through a player instance (as such that player must currently be a valid player object in the game when the function is called, to do what you’re describing you will need to make use of one of the group API endpoints, in specific this one.
It takes a user ID and provides a list of groups the user matching the specified user ID is in with their roles in those groups (this includes the name of the role and the rank).