So I'm testing my script, which is a day/night script, but it is like the one from the game Fantastic Frontier. Where it just jumps to night time after a couple minutes, and jumps back to day time. The script works, but I have it in a While True Do loop. And I've been trying to find another way of changing it or making it better.

This is the day/night script, I'm trying to make it where things appear during day, and then disappear during night and vice versa.


SF = game.Workspace.SF
S1 = SF.S1
S2 = SF.S2
DM = SF.ds
NM = SF.ns

F1 = game.ServerStorage.NPCS


while true do
	wait(0.01)
	
	game.Lighting.TimeOfDay = (8)
game.Lighting.FogEnd = (300)
game.Lighting.FogColor = Color3.fromRGB(255, 221, 181)
	F1.Parent = game.ServerStorage
	S1:Play()
	wait(7)
	S1:Stop()
	DM:Play()
	DM.Volume = (1)
	wait(10)
	DM.Volume = (0)
	DM:Stop()
	game.Lighting.TimeOfDay = (13)
	
game.Lighting.FogEnd = (80)
game.Lighting.FogColor = Color3.fromRGB(77, 75, 111)
	F1.Parent = workspace
	S2:Play()
	S2.CompressorSoundEffect.Enabled = true
	wait(14)
	S2:Stop()
	NM:Play()
	NM.Volume = (1)
	S2.CompressorSoundEffect.Enabled = false
	wait(10)
	NM:Stop()
	NM.Volume = (0)
end

This script works, but I wish it was more organized. I just want the filters and the sounds enabled for this script. I don't want everything jumbled in one script, so I made another script with PartA and PartB, where if it is day PartA's transparency would be set to 1, if it is night it will turn to 0 and PartB's will be 1.

local Time = game.Lighting.ClockTime
game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
	

	if Time >= 8 or Time <= 13 then
		print("It's day.")
		game.Workspace.PartA.Transparency = 1
		game.Workspace.PartB.Transparency = 0
	else
		print("It's night.")
		game.Workspace.PartA.Transparency = 0
		game.Workspace.PartB.Transparency = 1
	end
end)

The problem lies after PartA goes invisible, it just stays invisible after night. And PartB doesn't even change at all. And it just keeps printing "It's day." even when it turns night time. It doesn't print anything invalid in the output. I'm kinda confused on this one.