Attempt to compare number <= boolean

So I have gotten this error (the error is the title to the topic), and I am wondering what Iโ€™m doing wrong! Please help! :slight_smile:

local Lock = true

game.Players.PlayerAdded:Connect(function(Player)
	
	if Lock and not Player:GetRankInGroup(11941815) >= 15 then
		Player:Kick("\n๐Ÿ | Commander System | ๐Ÿ\nThe training center is currently not open! Please try again later.")
	end
	
	Player.Chatted:Connect(function(Message)
		if string.lower(string.sub(Message,1,7)) == "!unlock" and Player.TeamColor == BrickColor.new("Bright bluish green") then
			Lock = false
		end
	end)
end)
1 Like

The not inside your not Player:GetRankInGroup(id) >= 15 statement is turning the API result into a boolean value, then you try to check if true/false is bigger than 15 which doesnโ€™t make sense. Instead of adding a not in front of the statement try reversing the condition depending on what you try to do(for example the reverse of >= is <)

2 Likes

I will try this out right now! (I kind of forget operators sometimes, thanks for pointing that out.)

1 Like

To add onto this, you can also use ( ) to explicitly state the order you want the operations to happen in. I do that a lot in my code, sometimes unnecessarily, just to make sure itโ€™s not causing me any hidden bugs.

Reversing the <= / >= is the cleanest solution as mentioned, but just know you can use parentheses to help you out too for other situations!

if Lock and (Player:GetRankInGroup(11941815) < 15) then

You could have just done it like this, the function returns 0 if the player is not a member of the group. A group rank of 0 represents the โ€œGuestโ€ rank (a non-group member).

For me later, please disregard this post:

local Locked = true

game.Players.PlayerAdded:Connect(function(Player)
    if Locked and (Player:GetRankInGroup(11941815) < 9) then
        game.Workspace["TrainingDoor3"].CanCollide = true
    end
    
    Player.Chatted:Connect(function(Message)
         if (string.lower(string.sub(Message,1,7)) == "!admit3") and (Player.Team == "Trainer") then
           Locked = false
        elseif (string.lower(string.sub(Message,1,9)) == "!unadmit3") and (Player.Team == "Trainer") then
            Locked = true
        end
    end)
end)