:GetRankInGroup(Id) Sometimes errors out "Player is not in Workspace"

So I have this code:

if CanLoadCommands == false then
	if Player then
		if Player:GetRankInGroup(901313) >= 150 then
		     CanLoadCommands = true

This code has a chance of erroring out and giving me the error “Player is not in Workspace” at the line where it says “if Player:GetRankInGroup(901313) >= 150 then”. My guess is this happens if the player gets kicked before this line happens.

How is this a bug, other than the misleading error message? Whoever implemented :GetRankInGroup() decided it shouldn’t work if the player left the game.

Cause erroring “Player is not in Players” just sounds strange.

Error should probably be “Player is not in DataModel”


DataModel is the more internal name for “game”. I’ve seen a few other errors use it.

1 Like

The real fix is that :GetRankInGroup should be deprecated in favor of a new method: GroupService:GetRankInGroup(int userId, int groupId). That way it’s not even necessary to have the player in the game. The old method will continue to function of course.