Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

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

Asked by 3 years ago

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

Log in to vote
2
Answered by
zane21225 243 Moderation Voter
3 years ago

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)
1
That's not what I asked, I asked is there a way to see if they player is certain ranks. Golden_Tyler115 54 — 3y
0
A player can't be multiple ranks in a group. My script is printing which rank the user is (in the specified group). zane21225 243 — 3y
Ad
Log in to vote
0
Answered by
uhi_o 417 Moderation Voter
3 years ago

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

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. zane21225 243 — 3y

Answer this question