Attempt to compare boolean < number

Hello, i’m trying to make a command that bans the player from the server. But I want to check if the player running that command is higher than the target’s rank in the group.

commands.serverban = function(player,target)
	if target and not player:GetRankInGroup(9017622) < target:GetRankInGroup(9017622) then --Error
		target:Kick(player.Name.." has banned you from the server!")
		game.ReplicatedStorage.BindableEvents.AddBannedPlayer:Fire(target)
		logEvent:FireAllClients(player.Name.." used 'serverban' on player "..target.Name,true)
	end
end

I get the error Attempt to compare boolean < number.

target is a bool, are you sure that what you’re passing is a Player Object?

Target is an objectvalue of the player that you want to serverban

1 Like

Are you sure though? Can you try this to make sure you’re not sending a BoolValue or a Bool?

commands.serverban = function(player,target)
    print("Player: ", player)
    print("Target: ", target)
	if target and not player:GetRankInGroup(9017622) < target:GetRankInGroup(9017622) then --Error
		target:Kick(player.Name.." has banned you from the server!")
		game.ReplicatedStorage.BindableEvents.AddBannedPlayer:Fire(target)
		logEvent:FireAllClients(player.Name.." used 'serverban' on player "..target.Name,true)
	end
end

Try this:

if target and not (player:GetRankInGroup(9017622) < target:GetRankInGroup(9017622)) then

image
It registers that there is a target

This has worked for me. Thank you!