Im trying to make it where a sound plays only once whent he lights turn on/off, but since the program needs to keep checking if the lights are on or off, it also constantly plays the sound. I've tried solving this by placing a separate while loop that detects what time of day it is and when to play the sound. Any help?
while true do
lighting.ClockTime = currenttime
for _, Lamp in ipairs(Lamps) do
if (currenttime >= 6 and currenttime <= 19) then
Lamp.Material = Enum.Material.Plastic
Lamp.PointLight.Enabled = false
else
Lamp.Material = Enum.Material.Neon
Lamp.PointLight.Enabled = true
end
end
currenttime += .01
if currenttime >= 24 then
currenttime = 0
end
wait()
end
while true do
for _, Lamp in ipairs(Lamps) do
if (currenttime >= 6 and currenttime <= 7) then
Lamp.LightsOff:Play()
end
end
end
