GetRankInGroup Not working

Hello developers, I am having an issue with GetRankInGroup, I have checked the Wiki using this link here, Player | Roblox Creator Documentation and I copied the exact same script at the bottom of the padge into a local script in my game and it doesnt work, am I just being stupid or is it a studio bug, can someone please let me know. The issue is the same in game and in studio, nothing appears in the output or dev console, here is the script if you need it.

game.Players.PlayerAdded:Connect(function(Player)
    if Player:GetRankInGroup(2) == 255 then
        print("Player is the owner of the group, 'LOL'!")
    else
        print("Player is NOT the owner of the group, 'LOL'!")
    end
end)

I would have posted this in Bug Reports, however for some reason I cant post in that area.

What do you mean by “it doesn’t work”? Do you mean it’s saying "Player is NOT the owner of the group, 'LOL'!"? If so, that’s because the player is not in the group with ID 2.

Did you set the group to your group ID?

What I mean by it doesnt work is, it doesnt do anything, it doesnt print “Player is NOT the owner of the group, ‘LOL’!”

No, as it should work by printing “Player is NOT the owner of the group, ‘LOL’!”. Thats what I am trying to say, but it doesnt print anything.

  1. Where did you put the script with this code? (put it in StarterPlayers > StarterPlayerScripts
  2. Since it’s a local script, no need for the PlayerAdded event. Just use game.Players.LocalPlayer
if game.Players.LocalPlayer:GetRankInGroup(2) == 255 then
        print("Player is the owner of the group, 'LOL'!")
else
        print("Player is NOT the owner of the group, 'LOL'!")
end

I put it in a GUI in starter GUI, as what my end goal of this is to make a GUI visible if a player is ranked over a certain group rank, but when I do the exact same thing but instead of printing it is

script.Parent.Visible = false

The GUI remains visible.

I’m pretty sure your GroupID isn’t (2)

I know its not, but it should just print “Player is NOT the owner of the group, ‘LOL’!” Even though my group doesnt have the ID of 2.

1 Like

Could I see your StarterGui part of explorer and full script in it’s current state? This is an unusual issue indeed. Are you 100% certain there is no HTTP error or something alike?

I am certain there isnt a HTTP error, but heres the explorer,image The local script contains the Group rank script.

Why did you put a script there? Can you also show the code?

Did you try the script I told you to use? I’m assuming the issue here is because the EnableJumping GUI is only getting replicated to the player after the player joins, so the PlayerAdded event doesn’t run at all.

if game.Players.LocalPlayer:GetRankInGroup(2) == 255 then
    print("Player is the owner of the group, 'LOL'!")
else
    print("Player is NOT the owner of the group, 'LOL'!")
end

Yes, it is in a local script, also the reason I put it there is as the goal of what I am trying to do it is make it so that the GUI goes invisible, but I am just using the script from the Wiki as it is familiar to other people.

If that’s what you want then just run…

local player = game.Players.LocalPlayer

if player:GetRankInGroup(2) == 255 then
	print("Player is the owner of the group, 'LOL'!")
else
	print("Player is NOT the owner of the group, 'LOL'!")
end

I will try that real quick, however, would it just be a case of the Wiki being out of date?

Not really. I’m guessing what the Wiki is assuming that the code is put inside a ServerScript.
In your case, you have to make some small changes so it runs for you just as fine.

Ah ok, thank you all so much for your help, I would suggest to the devs at roblox if they can change it on the wiki, as it will confuse a lot of new people to scripting like myself.

1 Like

Maybe, but it did say…

This event does not work as expected in solo mode , because the player is created before scripts that connect to PlayerAdded run. To handle this case, as well as cases in which the script is added into the game after a player enters, create an OnPlayerAdded function that you can call to handle a player’s entrance.