Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a sound stop playing at night, and start at day time?

Asked by 2 years ago

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.

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

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]

0
Thanks, where should I put this script? I'll let you know if it works. RunkerSecurity 6 — 2y
0
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.] Jay123abc2 241 — 2y
0
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 ???? RunkerSecurity 6 — 2y
0
Locate the script, or the sound? Jay123abc2 241 — 2y
View all comments (8 more)
0
local sound = [Locate your sound here] the sound. RunkerSecurity 6 — 2y
0
I think I got it, I will test. RunkerSecurity 6 — 2y
0
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! Jay123abc2 241 — 2y
0
Okay i still hear it playing after 17 i will try see if the day night cycle is causing the problem. RunkerSecurity 6 — 2y
0
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? RunkerSecurity 6 — 2y
0
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! Jay123abc2 241 — 2y
0
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. RunkerSecurity 6 — 2y
0
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. Jay123abc2 241 — 2y
Ad

Answer this question