Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help with music changing at night script?

local lighting = game:GetService("Lighting")
local sound1 = script:WaitForChild("Sound1")
local sound2 = script:WaitForChild("Sound2")
sound1.Looped = true
sound2.Looped = false
sound1:Play()
local function onTimeChanged()
if lighting.ClockTime == 20 then
sound1:Stop()
wait(580)
sound2:Play()
elseif lighting.ClockTime == 6 then
   sound2:Stop()
wait(.1)
sound1:Play()
   end
end

lighting:GetPropertyChangedSignal("ClockTime"):Connect(onTimeChanged)

I want the music to stop at 20:00:00, but start again at 6:00:00. So I did the math (60 * 4 = 240, 240 * 2 = 580. I did this because the time changes by one minute every two seconds.) but the problem is that the music doesn't even stop at 20:00:00.

1 comment

0

il try to figure it out

1 answer

try this:

local s = Instance.new("Sound")

s.Name = "Sound1" s.SoundId = "Change this to your id" s.Volume = 1 s.Looped = true s.archivable = false

s.Parent = game.Workspace

duplicate it and change it to Sound2

if it does not work you can comment on one of mine and say It does not work because it was made in 2017

This discussion is preserved as it was. New answers, comments, and votes are closed.