I am a newbie at scripting and acquire serious help. My friend wants me to script him a series of flashing lights(Parts that change material one at a time which will conclude a series of flashing lights after night time arrives and the time needed to change material is at least 1 second). Everything went accordingly to my script(which is showcased below) until the neon parts began slowing down and then randomly started flashing around without being in sync. Any help please?
local lightPart = script.Parent while true do wait(1) if game.Lighting:GetMinutesAfterMidnight() > 6 * 60 then`` ``lightPart.Material = Enum.Material.Plastic`` end if game.Lighting:GetMinutesAfterMidnight() > 18 * 60 then lightPart.Material = Enum.Material.Neon wait(1) lightPart.Material = Enum.Material.Plastic wait(1) lightPart.Material = Enum.Material.Plastic wait(1) lightPart.Material = Enum.Material.Plastic wait(1) lightPart.Material = Enum.Material.Neon wait(1) lightPart.Material = Enum.Material.Plastic wait(1) lightPart.Material = Enum.Material.Neon wait(1) lightPart.Material = Enum.Material.Plastic wait(1) lightPart.Material = Enum.Material.Plastic wait(1) lightPart.Material = Enum.Material.Plastic wait(1) lightPart.Material = Enum.Material.Neon wait(1) lightPart.Material = Enum.Material.Plastic wait(1) end end
Edit: I have changed the script below because the problem is that the lights flash at irregular intervals, from what I can see.
Try this:
local debounce = false game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function() if debounce == true then return end if game.Lighting.ClockTime > 18 then debounce = true repeat lightPart.Material = Enum.Material.Neon wait(1) lightPart.Material = Enum.Material.Plastic wait(1) until game.Lighting.ClockTime >= 6 and game.Lighting.ClockTime < 6.01 debounce = false end end)