Help: Light not turning off after certain time

I’m having a small problem; My script which is supposed to turn off lights at one single time (6:30 am using the roblox ClockTime); I know i’m supposed to use a coroutine (I did actually, I’m new to using those so I have no idea if it’s that’s the problem)

What are you trying to get?
A script which turns on a spotlight and turns on an effect at around 18.1 (roblox clocktime; of course.) until 6.3.

What’s wrong?
The Bottom Line, that turns off the light when it’s above 6.3.

The Script itself:

--// Locals

local LightEffect = script.Parent.LightEffect.light
local SpotLight = script.Parent.Parent.LightPart.SpotLight

--// Main

local thread_Off = coroutine.create(function()
	while true do
		wait(0.5)
    if game.Lighting.ClockTime > 6.3 then
			LightEffect.Enabled = false
			SpotLight.Enabled = false
			SpotLight.Parent.BrickColor = BrickColor.new("Dark stone grey")
			SpotLight.Parent.Material = Enum.Material.SmoothPlastic
		end
	end	
end)



while true do
	wait(0.5)
	if game.Lighting.ClockTime > 18.1 then
		LightEffect.Enabled = true
		SpotLight.Enabled = true
		SpotLight.Parent.BrickColor = BrickColor.new("Institutional white")
		SpotLight.Parent.Material = Enum.Material.Neon
	end
end


coroutine.resume(thread_Off)
1 Like

You could just detect ClockTime changes like this:

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
     if game.Lighitng.ClockTime > 16.3 then
        -- Do stuff
    end
end)

Neither works now, It still stays up after > 18.1 and 6.3

Try this.maybe it work…im sorry if wrong…im still learning

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
     if game.Lighitng.ClockTime > 16.3 then
        -- Do stuff
      elseif game.Lighting.ClockTime > 18.1 then
        -- Do stuff
    end
end)