Trying to make a working street light post

I want to make a Street light post

Workspace.Lightposts.Script:2: attempt to compare string < number 

I tried using >= and <= and < and > but nothing worked.

The script:

while true do
	if game.Lighting.TimeOfDay < 6.3 or game.Lighting.TimeOfDay > 17.6 then
		for i,v in pairs(script.Parent:GetChildren()) do
			if v.ClassName == "Model" then
				v.Part.SpotLight.Enabled = true
			end
		end
	else
		for i,v in pairs(script.Parent:GetChildren()) do
			if v.ClassName == "Model" then
				v.Part.SpotLight.Enabled = false
			end
		end
	end
	wait(0.1)
end

Could anyone please help me solve this problem?

1 Like

Looks like I solved the problem! I set TimeOfDay instead of ClockTime. I believe TimeOfDay isn’t a string.

1 Like