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!
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)
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 <)
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).
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)