[SOLVED] "Players.kdopdaux1803.PlayerScripts.FullScript:5: attempt to compare boolean <= number"

Hello guys i found another issue to my game called Cyril’s Difficulty Chart Obby.

Script:

if game.Players.LocalPlayer.AccountAge <= 7 then
	game.Players.LocalPlayer:Kick("You are not allowed to be here because you have the account age of "..game.Players.LocalPlayer.AccountAge.." days")
end

if game.Players.LocalPlayer.AccountAge == 0<=7 then -- ISSUE ! You can remove it after you fixed it (Line 5)
	print(game.Players.LocalPlayer.Name.." joined with the account age of "..game.Players.LocalPlayer.AccountAge.." days and he is not allowed to join in the game.")
	if game.Players.LocalPlayer.AccountAge == 1 then
		print(game.Players.LocalPlayer.Name.." joined with the account age of "..game.Players.LocalPlayer.AccountAge.." day and he is not allowed to join in the game.")
	elseif game.Players.LocalPlayer.AccountAge == 8<=60 then
		print(game.Players.LocalPlayer.Name.." joined with the account age of "..game.Players.LocalPlayer.AccountAge.." sounds pretty new, huh ?")
	elseif game.Players.LocalPlayer.AccountAge == 61<=150 then
		print(game.Players.LocalPlayer.Name.." joined with the account age of "..game.Players.LocalPlayer.AccountAge.." days.")
	elseif game.Players.LocalPlayer.AccountAge == 151<=182 then
		print(game.Players.LocalPlayer.Name.." joined with the account age of "..game.Players.LocalPlayer.AccountAge.." days. Almost half of the year.")
	elseif game.Players.LocalPlayer.AccountAge == 183<=365 then
		print(game.Players.LocalPlayer.Name.." joined with the account age of "..game.Players.LocalPlayer.AccountAge.." days. Past of half of the year.")
	elseif game.Players.LocalPlayer.AccountAge == 366<=730 then
		print(game.Players.LocalPlayer.Name.." joined with the account age of "..game.Players.LocalPlayer.AccountAge.." days. Past a year, now.")
	elseif game.Players.LocalPlayer.AccountAge == 731<=1095 then
		print(game.Players.LocalPlayer.Name.." joined with the account age of "..game.Players.LocalPlayer.AccountAge.." days. Past 2 year, now.")
	elseif game.Players.LocalPlayer.AccountAge == 1096<=1460 then
		print(game.Players.LocalPlayer.Name.." joined with the account age of "..game.Players.LocalPlayer.AccountAge.." days. Past 3 year, now.")
	elseif game.Players.LocalPlayer.AccountAge == 1461<=1825 then
		print(game.Players.LocalPlayer.Name.." joined with the account age of "..game.Players.LocalPlayer.AccountAge.." days. Past 4 year, now.")
	elseif game.Players.LocalPlayer.AccountAge <= 1826 then
		print(game.Players.LocalPlayer.Name.." joined with the account age of "..game.Players.LocalPlayer.AccountAge.." days. Over 5 year, now. This incredible, this account is still exists, somehow...")
	end
end

local BannedUser = {"Eddy0107"}
local LocalPlayer = game.Players.LocalPlayer
local PlayerJoined = game.Players.PlayerAdded
local msg = "You have been permenantly banned for destroying the whole map that took over 5 freaking hours to make ! Now you won't get any chances to be here and that what you GET for destroying a map in progress..."

if table.find(BannedUser, LocalPlayer.Name) then
	table.insert(BannedUser, LocalPlayer.Name)
	LocalPlayer:Kick(msg)
	print(BannedUser.." is permenantly banned !")
end

It’s a LocalScript…

No videos unfortunately, and no screenshots…

Any help is appreciated, thanks !

2 Likes

I think your problem is that you have 2 comparisons on line 5. (comparisons in parenthesis below)

if game.Players.LocalPlayer.AccountAge (==) 0(<=)7 then

3 Likes

It was a great idea but i don’t know why it didn’t worked…

If we do:

if game.Players.LocalPlayer.AccountAge (==) 0(<=)7 then

This, the AccountAge is Yellow…

Plus, there’s 8 error…

bandicam 2022-08-09 20-46-58-946

1 Like

I think its


if game.Players.LocalPlayer.AccountAge <= 7 then

2 Likes

Your comparison syntax is all wrong. Your comparisons should be:

game.Players.LocalPlayer.AccountAge > 8 and game.Players.LocalPlayer.AccountAge <=60

Alternatively, you can write a function for this:

local function isInRange(value: number, min: number, max: number) : boolean
    return value == math.clamp(value, min, max)
end
2 Likes

You cant do this

game.Players.LocalPlayer.AccountAge == 0<=7

Try this and change it first all the code, just change the numbers

game.Players.LocalPlayer.AccountAge == 0 and game.Players.LocalPlayer.AccountAge <=7

I’all make a better code for you in a bit

2 Likes

It’s not wrong…

Why do you mean by that ?

Errors.

It errors me, try by doing:

game.Players.LocalPlayer.AccountAge == 0 and game.Players.LocalPlayer.AccountAge <=7

I’m using:

elseif game.Players.LocalPlayer.AccountAge == 0 and game.Players.LocalPlayer.AccountAge <=7 then

Instead…

1 Like

Oh yeah for the 8-60 on its


elseif game.Players.LocalPlayer.AccountAge >= 8 and game.Players.LocalPlayer.AccountAge <= 60 then

1 Like

Ya have the if and elseif I just said change the comparison part to this

1 Like

I said i use elseif not If or if.

Your code is doing this:

(n == n) <= n

That’s what the error means. It’s evaluating a true/false first, then you’re seeing if the boolean is less than or equal to a number

Your code should look like this:

local localPlayer = game:GetService("Players").LocalPlayer -- the localplayer
local accountAge = localPlayer.AccountAge -- the player's account age
-- it's better to make variables, then to keep indexing

local function isInRange(min: number, max: number) : boolean
    -- returns whether or not the player's account age falls within certain days (min, max)
	return accountAge == math.clamp(accountAge, min, max)
end

if accountAge <= 7 then
	-- This is unsecure, but ok
	localPlayer:Kick("You are not allowed to be here because you have the account age of "..accountAge.." days")
end

if isInRange(8, 60) then
	-- fill in these spaces with your messages
elseif isInRange(61, 150) then
	
elseif isInRange(151, 182) then
	
elseif isInRange(183, 365) then
	
elseif isInRange(366, 730) then
	
elseif isInRange(791, 1095) then
	
elseif isInRange(1096, 1460) then
	
elseif isInRange(1461, 1825) then
	
elseif accountAge >= 1826 then
	print("over 5 years")
end

local BannedUser = {"Eddy0107"}
local LocalPlayer = game.Players.LocalPlayer
local PlayerJoined = game.Players.PlayerAdded
local msg = "You have been permenantly banned for destroying the whole map that took over 5 freaking hours to make ! Now you won't get any chances to be here and that what you GET for destroying a map in progress..."

if table.find(BannedUser, LocalPlayer.Name) then
	table.insert(BannedUser, LocalPlayer.Name)
	LocalPlayer:Kick(msg)
end
2 Likes
  1. You’ve got an issue with this line, instead do if game.Players.LocalPlayer.AccountAge >=7 then

2 . You cannot kick a player from a local script, instead use a server script to kick the player.

  1. I’m not sure if you are actually trying to permanently ban a user here, but adding the username into a table will not work and it will be just reset for every player since it’s a local script, instead try using DataStoreService.

Also consider using a table and for loops instead of using that many if statements, it’s a good practice.

2 Likes

You are truly wrong after the 2nd issue…

1 Like

Modifying the script but thanks !

Just wait for the script…

Issue at Line 17 / Line 19 / Line 21 / Line 23 / Line 25 / Line 27 / Line 29 / Line 31 and (I guess) Line 33.

local localPlayer = game:GetService("Players").LocalPlayer -- the localplayer
local accountAge = localPlayer.AccountAge -- the player's account age
local accountAgelimitTojoin = 8 -- Limitation to people to the accounts...
-- it's better to make variables, then to keep indexing

local function isInRange(min: number, max: number) : boolean
	-- returns whether or not the player's account age falls within certain days (min, max)
	return accountAge == math.clamp(accountAge, min, max)
end

if accountAge <= 7 then
	wait(1)
	localPlayer:Kick("You are not allowed to be here because you have the account age of "..accountAge.." days. You need to be "..accountAgelimitTojoin.." to be able to join in this game !")
end

if isInRange(8, 60) then
	print("This account age is "..isInRange(8,60).." days old. This account is now allowed to be placed in here...")
elseif isInRange(61, 150) then
	print("This account age is "..isInRange(61,150).." days old. Less then half a year that the account is here...")
elseif isInRange(151, 182) then
	print("This account age is "..isInRange(151,182).." days old. More then half a year that the account exists...")
elseif isInRange(183, 365) then
	print("This account age is "..isInRange(183,365).." days old. More then half a year that the account exists...")
elseif isInRange(366, 730) then
	print("This account age is "..isInRange(366,730).." days old. More then a year that the account exists...")
elseif isInRange(731, 1095) then
	print("This account age is "..isInRange(731,1095).." days old. More then 2 years that the account exists...")
elseif isInRange(1096, 1460) then
	print("This account age is "..isInRange(1096,1460).." days old. More then 3 years that the account exists...")
elseif isInRange(1461, 1825) then
	print("This account age is "..isInRange(1461,1825).." days old. More then over then 4 years that the account exists...")
elseif accountAge >= 1826 then
	print("I can't belive it, a player that is 5 years joined the server ! The player's AccountAge is "..accountAge.." days old !")
end

local BannedUser = {"Eddy0107"}
local LocalPlayer = game.Players.LocalPlayer
local PlayerJoined = game.Players.PlayerAdded
local msg = "You have been permenantly banned for destroying the whole map that took over 5 freaking hours to make ! Now you won't get any chances to be here and that what you GET for destroying a map in progress..."

if table.find(BannedUser, LocalPlayer.Name) then
	table.insert(BannedUser, LocalPlayer.Name)
	LocalPlayer:Kick(msg)
end
1 Like

Replace isInRange() in the concatenations with the accountAge variable. Like this:

print("This account age is "..accountAge.." days old. This account is now allowed to be placed in here...")

Yes

2 Likes

Alright thanks should i get a solution ?

local localPlayer = game:GetService("Players").LocalPlayer -- the localplayer
local accountAge = localPlayer.AccountAge -- the player's account age
local accountAgelimitTojoin = 8 -- Limitation to people to the accounts...
-- it's better to make variables, then to keep indexing

local function isInRange(min: number, max: number) : boolean
	-- returns whether or not the player's account age falls within certain days (min, max)
	return accountAge == math.clamp(accountAge, min, max)
end

if accountAge <= 7 then
	wait(1)
	localPlayer:Kick("You are not allowed to be here because you have the account age of "..accountAge.." days. You need to be "..accountAgelimitTojoin.." to be able to join in this game !")
end

if isInRange(8, 60) then
	print("This account age is "..accountAge.." days old. This account is now allowed to be placed in here...")
elseif isInRange(61, 150) then
	print("This account age is "..accountAge.." days old.")
elseif isInRange(151, 182) then
	print("This account age is "..accountAge.." days old. Less then half a year that the account exists...")
elseif isInRange(183, 365) then
	print("This account age is "..accountAge.." days old. More then half a year that the account exists...")
elseif isInRange(366, 730) then
	print("This account age is "..accountAge.." days old. More then a year that the account exists...")
elseif isInRange(731, 1095) then
	print("This account age is "..accountAge.." days old. More then 2 years that the account exists...")
elseif isInRange(1096, 1460) then
	print("This account age is "..accountAge.." days old. More then 3 years that the account exists...")
elseif isInRange(1461, 1825) then
	print("This account age is "..accountAge.." days old. More then 4 years that the account exists...")
elseif accountAge >= 1826 then
	print("I can't belive it, a player that is 5 years joined the server ! The player's AccountAge is "..accountAge.." days old !")
end

local BannedUser = {"Eddy0107"}
local LocalPlayer = game.Players.LocalPlayer
local PlayerJoined = game.Players.PlayerAdded
local msg = "You have been permenantly banned for destroying the whole map that took over 5 freaking hours to make ! Now you won't get any chances to be here and that what you GET for destroying a map in progress..."

if table.find(BannedUser, LocalPlayer.Name) then
	table.insert(BannedUser, LocalPlayer.Name)
	LocalPlayer:Kick(msg)
end

Sorry if i copy you.

Thank you…

1 Like

@NimaDev Thanks for the help !
@HugeCoolboy2007 Thanks to try to help me.
@schaap5347 Thanks to try to help me.
@msix29 Thanks to try to help me.
@AkroThorn Thanks to try to help me.

1 Like