invalid operands using bool and int in operator <

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Rowan

I keep getting this error message.
This is my code.

extends TextureRect

func _ready():

var Day = load('res://Assets/Background.png')
var Night = load('res://Assets/Background_Night.png')
var time = OS.get_time()
var hour = time.hour

if 6 < hour < 20:
	.set_texture(Day)
else:
	.set_texture(Night)

Thank you, @dancaer69 and @timothybrentwood! You both gave quick, useful responses!

Rowan | 2021-05-29 19:30

:bust_in_silhouette: Reply From: dancaer69

I don’t think that you can do that in gdscript. Do it like this:

if hour > 6 and hour < 20:
:bust_in_silhouette: Reply From: timothybrentwood

if 6 < hour < 20:
needs to be
if (6 < hour) and (hour < 20):

No complex inequalities without an and or or statement. What was happening is it evaluated 6 < hour which resolved to either true or false then it tried to evaluate true < 20 which just doesn’t make sense.