Lighting Error (attempt to compare number <= nil)

Hey there,

I got this weird error and I don’t know how to fix.

image

local no = game.ServerStorage:WaitForChild("Yes")

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function(clockTime)
	if (clockTime >= 10) or (clockTime <= 12) then --error line here!
		print("Time is between 10:00 and 12:00")
	else
		print("Oh no! It is not between 10:00 and 12:00, current time: "..clockTime)
	end
end)

Help is appreciated, thanks.

The :GetPropertyChangedSignal function has no parameter. This should be fixed.

local no = game.ServerStorage:WaitForChild("Yes")

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
    local clockTime = game.Lighting.ClockTime
	if (clockTime >= 10) or (clockTime <= 12) then --error line here!
		print("Time is between 10:00 and 12:00")
	else
		print("Oh no! It is not between 10:00 and 12:00, current time: "..clockTime)
	end
end)

Instance:GetPropertyChangedSignal() doesn’t automatically have clockTime as an argument (it doesn’t return any arguments), you need to manually fetch it yourself as mentioned above.

Thank you for notifying me about that, thought I was epic gamer lol (jk)

Yea. I got one little problem which I’ll reply to with @XxAkaDuyxX

Works!

One thing, after it passes 12:00:00 it’ll keep saying “Time is between 10:00 and 12:00”

Any fix? I didn’t touch anything else on the script.

After checking your script, Replace “or” to “and”.

1 Like

Works!

Thank you so much!

1 Like