• Attempt to compare number with boolean
    7 replies, posted
I don't know how to fix this error. "Attempt to compare number with boolean" This is a clientside script, and here is the code: The first line is the one that errors. I do not know how to fix this :S [lua] if string.len(CName) < 10 & string.len(CName) >= 1 & CompanyCallPrice:GetValue() > 0 & CompanyCallPrice:GetValue() <= 100 & CompanyTextPrice:GetValue() > 0 & CompanyTextPrice:GetValue() <= 50 then [/lua] It is weird because the string.len outputs a value, and I check if the value is higher/lesser then X [b]Solution for you, if you find this post somewhere in the future and have the same problem[/b] Change all the "&" to "and" in the IF statement!
The error is pretty self explanatory: Somewhere, you're trying to compare a number to a boolean, and that isn't allowed. What is "CompanyCallPrice" and "CompanyTextPrice"?
The error is specificly here, since I made the IF statement in 3 lines, to detect where the error is: "if string.len(CName) < 10 & string.len(CName) >= 1 & " CompanyCallPrive and TextPrice are two values that you select with a derma slider thing. [b]Edit:[/b] CName is a textbox entry in Derma too. If I print CName and "string.len(CName)" in console when if statement is printed, I see that CName is a string with a name (as it should), and the string.len is value contains how many characters the CName got (which is correct, and supposed to be) So I dont see why it doesnt allow me to check if CName lenght is greater/lesser then X
What is the exact line of code that is producing the error?
[QUOTE=Blt950;32679090]The error is specificly here, since I made the IF statement in 3 lines, to detect where the error is: "if string.len(CName) < 10 & string.len(CName) >= 1 & "[/QUOTE] [editline]8th October 2011[/editline] Also it's weird that string.len returs Integer, and I can't check it with a simple IF statement?
Okey, I found a solution here! It was so simple as changing all the "&" to "and" in the IF STATEMENT. Thanks for the help anyway :)
You probably want to use && as I don't think you are trying to use a bitwise operator. [editline] Just noticed I got ninjad.
It's pretty embarassing trying to help someone, only to realize that you missed something as obvious as that lol
Sorry, you need to Log In to post a reply to this thread.