Checking if a player isn't in a group

I am trying to make a team selector for our game, and there is a team a player can join if they are level 1 in the group or not in the group at all. However, on an alt account, when I join the game not in the group it does not work (the button destroys), but if I am in the group it works.

I am using :GetRankInGroup to see if they are in or not in the group, and I have tried :IsInGroup and it is the same result.

The portion of the code giving me problems:

				if v.Name == "Teamname" then
					local rank = player:GetRankInGroup(ID)
					if rank == 1 or 0 or player:IsInGroup(ID) == false then
						print(slot, v.Name)
						v.Position = stuff.Slots:FindFirstChild(slot).Position
						slot = slot + 1
					else
						v:Destroy()
					end
				end
3 Likes

You could try and use IsInGroup

For example,

   if player:IsInGroup(7) then                    
      print "Player is in the Roblox Fan club!"     
   else
      print("User is not in the roblox fan club")
   end
1 Like

The Rank ‘Guest’ is classed as anyone not in the group, so this can be done by

if player:GetRankInGroup(GROUPID) == 0 then -- not in group

Or, you could simply transform it into an if statement.

if player:IsInGroup(GROUPID) then
   -- is in group
else
    -- not in group
end

I have already tried IsInGroup and I am already doing GetRankInGroup == 0, and both do not work for if the player is not in the group

They definitely work, it must be an error with the rest of your code.

1 Like

I am not getting any errors in the code or earlier in the script that could be stopping it

Make sure it’s a local Script, or that you have Player defined, and just do this;

local Player = game:GetService("Players").LocalPlayer
local ID = 1
if (not Player:IsInGroup(ID)) then
     print("Not in group!")
end
4 Likes

Still not working, but I can confirm that the GetRankInGroup == 1 part of the if statement is working, so it cannot be a problem with the actual if statement

Nevermind, this seems to have worked, but I was under the assumption it wasn’t because the test game was taking forever to actually publish.

why dont you just do

			if v.Name == "Teamname" then
				local rank = player:GetRankInGroup(ID)
				if rank == 1 or 0 or not player:IsInGroup(ID) then
					print(slot, v.Name)
					v.Position = stuff.Slots:FindFirstChild(slot).Position
					slot = slot + 1
				else
					v:Destroy()
				end
			end

This should be

if rank == 1 or rank == 0 or not player:IsInGroup(ID) then

or

if table.find({1, 0}, rank) or not player:IsInGroup(ID) then