Attempting to compare a number <= Boolean error

Alright so I’m making a automatic uniforms system that gives uniforms to players when they join the game, but I am getting the “attempting to compare a number <= boolean” error.

I looked at other posts but I couldn’t get how to fix it so here I am.

The script is below as well as the line that is giving the error, although I’m sure I need to adjust all the lines as there are other lines for other groups. You’ll get it once you see.

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		if plr:IsInGroup(15038816) and not plr.Name == "WakeTheDev" and not plr.Name == "MochaTheDev" then
			char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513567320"
			char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513570472"
		elseif plr:IsInGroup(15040213) then
			if plr:GetRankInGroup(15040213) <= 2 and not plr:GetRankInGroup(15040213) == 0 then
				char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513568836"
				char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513567796"
			elseif plr:GetRankInGroup(15040213) > 2 and not plr:GetRankInGroup(15040213) >= 100 then  -- This line is the error
				char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513570677"
				char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513567601"
			elseif plr:GetRankInGroup(15040213) >= 100 then
				char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513567320"
				char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513570472"
			end
		elseif plr:IsInGroup(15215864) then
			if plr:GetRankInGroup(15215864) <= 47 and not plr:GetRankInGroup(15215864) == 0 then
				char:WaitForChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=10078671923"
				char:WaitForChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=10059029769"
			elseif plr:GetRankInGroup(15215864) > 2 and not plr:GetRankInGroup(15215864) >= 97 then
				char:WaitForChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=10058943372"
				char:WaitForChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=10059029769"
			elseif plr:GetRankInGroup(15215864) >= 97 then
				char:WaitForChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=10078670257"
				char:WaitForChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=10059029769"
			end
		elseif plr:IsInGroup(15177154) then
			if plr:GetRankInGroup(15177154) <= 12 and not plr:GetRankInGroup(15177154) == 0 then
				char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513568836"
				char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513567796"
			elseif plr:GetRankInGroup(15177154) > 12 and not plr:GetRankInGroup(15177154) >= 99 then
				char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513570677"
				char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513567601"
			elseif plr:GetRankInGroup(15177154) >= 99 then
				char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513567320"
				char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513570472"
			end
		elseif plr:IsInGroup(15444520) then
			if plr:GetRankInGroup(15444520) <= 3 and not plr:GetRankInGroup(15444520) == 0 then
				char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513568836"
				char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513567796"
			elseif plr:GetRankInGroup(15444520) > 3 and not plr:GetRankInGroup(15444520) >= 100 then
				char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513570677"
				char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513567601"
			elseif plr:GetRankInGroup(15444520) >= 100 then
				char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513567320"
				char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513570472"
			end
		end
	end)
end)

The line that is erroring:

elseif plr:GetRankInGroup(15040213) > 2 and not plr:GetRankInGroup(15040213) >= 100 then
1 Like

Try to remove the “not” and replace it with something like ~
I once did this and for some reason “not” doesnt work with anything other than bools.
I could be completely wrong, just making a suggestion

As in like do ~= like “not equal to?”

Yep! That worked. Instead of doing the not >= whatever I just got rid of the not and flipped the > to <.

Thank you.

Try adding parentheses around the condition

elseif plr:GetRankInGroup(15040213) > 2 and not (plr:GetRankInGroup(15040213) >= 100) then
game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		if plr:IsInGroup(15038816) and not plr.Name == "WakeTheDev" and not plr.Name == "MochaTheDev" then
			char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513567320"
			char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513570472"
		elseif plr:IsInGroup(15040213) then
			if plr:GetRankInGroup(15040213) <= 2 and not (plr:GetRankInGroup(15040213) == 0) then
				char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513568836"
				char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513567796"
			elseif plr:GetRankInGroup(15040213) > 2 and not (plr:GetRankInGroup(15040213) >= 100) then  -- This line is the error
				char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513570677"
				char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513567601"
			elseif plr:GetRankInGroup(15040213) >= 100 then
				char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513567320"
				char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513570472"
			end
		elseif plr:IsInGroup(15215864) then
			if plr:GetRankInGroup(15215864) <= 47 and not (plr:GetRankInGroup(15215864) == 0) then
				char:WaitForChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=10078671923"
				char:WaitForChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=10059029769"
			elseif plr:GetRankInGroup(15215864) > 2 and not (plr:GetRankInGroup(15215864) >= 97) then
				char:WaitForChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=10058943372"
				char:WaitForChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=10059029769"
			elseif plr:GetRankInGroup(15215864) >= 97 then
				char:WaitForChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=10078670257"
				char:WaitForChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=10059029769"
			end
		elseif plr:IsInGroup(15177154) then
			if plr:GetRankInGroup(15177154) <= 12 and not (plr:GetRankInGroup(15177154) == 0) then
				char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513568836"
				char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513567796"
			elseif plr:GetRankInGroup(15177154) > 12 and not (plr:GetRankInGroup(15177154) >= 99) then
				char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513570677"
				char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513567601"
			elseif plr:GetRankInGroup(15177154) >= 99 then
				char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513567320"
				char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513570472"
			end
		elseif plr:IsInGroup(15444520) then
			if plr:GetRankInGroup(15444520) <= 3 and not (plr:GetRankInGroup(15444520) == 0) then
				char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513568836"
				char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513567796"
			elseif plr:GetRankInGroup(15444520) > 3 and not (plr:GetRankInGroup(15444520) >= 100) then
				char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513570677"
				char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513567601"
			elseif plr:GetRankInGroup(15444520) >= 100 then
				char:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://513567320"
				char:WaitForChild("Pants").PantsTemplate = "rbxassetid://513570472"
			end
		end
	end)
end)

You’d benefit from implementing tables into your code.

local t = { --Indices are group IDs, values contain clothing information.
	[15038816] = {
		{1, 513567320, 513570472} --First value is group rank, second value is shird ID and third value is pants ID.
	},
	
	[15040213] = {
		{100, 513567320, 513570472},
		{3, 513570677, 513567601},
		{1, 513568836, 513567796}
	},
	
	[15215864] = {
		{97, 10078670257, 10059029769},
		{3, 10058943372, 10059029769},
		{1, 10078671923, 10059029769}
	},
	
	[15177154] = {
		{99, 513567320, 513570472},
		{13, 513570677, 513567601},
		{1, 513568836, 513567796}
	},
	
	[15444520] = {
		{100, 513567320, 513570472},
		{4, 513570677, 513567601},
		{1, 513568836, 513567796}
	}
}

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		if not plr:HasAppearanceLoaded() then plr.CharacterAppearanceLoaded:Wait() end --Wait for character's appearance to load.
		local shirt = char:FindFirstChildOfClass("Shirt") or Instance.new("Shirt") --Fetch shirt or create a new one (if one doesn't exist).
		local pants = char:FindFirstChildOfClass("Pants") or Instance.new("Pants") --Fetch pants or create a new one (if one doens't exist).
		for id, data in pairs(t) do --Iterate over the main table.
			if plr:IsInGroup(id) then --Check if player is in the group.
				local rank = plr:GetRankInGroup(id) --Get the player's rank in the group.
				for _, value in ipairs(data) do --Iterate over the sub table.
					if rank > value[1] then --Check if player's rank is greater than the rank in the table.
						shirt.ShirtTemplate = "rbxassetid://"..value[2] --Apply shirt ID to shirt.
						pants.PantsTemplate = "rbxassetid://"..value[3] --Apply pant ID to pants.
						break --Break out of the inner loop.
					end
				end
				break --Break out of the outer loop.
			end
		end
		shirt.Parent = char --Put the shirt inside the character (necessary if a shirt was created).
		pants.Parent = char --Put the pants inside the character (necessary if a pants was created).
	end)
end)