How do I make a sound stop playing at night, and start at day time? I'm trying to make birds sing at day, but not at night. It seems simple, but I can't find a solution.
✓ ANSWER ACCEPTED
How do I make a sound stop playing at night, and start at day time?
1 answer
✓ Accepted answer
To do this, I am guessing you have a day / night cycle script using ClockTime in the game. Try this:
local sound = [Locate your sound here]
if game.Lighting.ClockTime >= 18 then
sound:Stop()
else
if game.Lighting.ClockTime >= 7 and game.Lighting.Clockdown <= 17 then
sound:Play()
end
end
[I did this from what I think, should work. So pls let me know if it wont work. {Try removing <= 17}. Also, if the time goes above 24 this will allways work as night]
This discussion is preserved as it was. New answers, comments, and votes are closed.

12 comments
Thanks, where should I put this script? I'll let you know if it works.
The script should work in server script service. But in my oppinion, it will be best in Lighting. You can then replace game.Lighting with script.Parent [If you put it DIRECTLY under lighting.]
I'm sorry for this, but how should I locate this? I know it's like SoundService.parent.script or something like that, but I'm really new to scripting ????
Locate the script, or the sound?
local sound = [Locate your sound here] the sound.
I think I got it, I will test.
yes, So if you have the soung in Sound Sevice. It will be game.SoundService.[SoundName], or if you have it in workspace as a model. It will be workspace.[ModelName].[SoundName] -- Feel free to ask anything else!
Okay i still hear it playing after 17 i will try see if the day night cycle is causing the problem.
I don't have the most used day/night cycle script but I have one where to ambient changes too, can this be a problem?
Is the day / night cycle a local script, or server sided script? [Any changes u do on a LOCAL script will be that client only]. So since this is made for a normal 'script', if the day / night script is local [client sided] this can break. Try changing them both to local scripts / normal scripts!
Both of them are normal scripts, day/night cycle is in workspace, the script you gave me is in ServerScriptService. I tried turning both to LocalScript but now the day/night cycle doesn't work.
K, revert them to normal scripts. Server sided. I was looking through things and found this: https://devforum.roblox.com/t/help-with-music-change-at-night-script/259657/2. This might help, but idk.