Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there a way I can do this if player:GetRankInGroup(7351851) == 1 or 2 or 3 or 4 or 5?

I've been wondering how to do this forever, it seams so easy, but I just can't figure it out!

All I need to know is how can I see if the player is multiple ranks, so if the players group rank is 2 but I want to allow 1 and 2 to do the function how can I do that. (other then elseif)

Please help! Thanks. -Tyler

2 answers

✓ Accepted answer

I whipped up a simple script that gets the player's rank in a group once they join the game.

I tested it out and it should work just fine.

local groupid = 4110331

game.Players.PlayerAdded:Connect(function(player)
	local rank = player:GetRankInGroup(groupid)
	print(rank)
	--insert what you want to do with the rank here
end)

2 comments

1

That's not what I asked, I asked is there a way to see if they player is certain ranks.

0

A player can't be multiple ranks in a group. My script is printing which rank the user is (in the specified group).

Your question is malformulated but I'm guessing you mean every rank above a certain one can run the same function?

local groupId = 7351851

game.Players.PlayerAdded:Connect(function(plr)
    if plr:GetRankInGroup(groupId) >= 5 then
        --Runs only for users with the RankId 5+ in the group 7351851
    end
end)

and to get a player's rank name would be GetRoleInGroup(groupId)

local groupId = 7351851

game.Players.PlayerAdded:Connect(function(plr)
    print(plr:GetRoleInGroup(7351851))
    if plr:GetRankInGroup(groupId) >= 5 then
        --Runs only for users with the RankId 5+ in the group 7351851
    end
end)

https://developer.roblox.com/en-us/api-reference/function/Player/GetRankInGroup

1 comment

0

His question was very offset, honestly I'm surprised that he even got 3 upvotes. Your answer is pretty good. I mean I can't imagine anything else that he'd need for checking group ranks.

This discussion is preserved as it was. New answers, comments, and votes are closed.