You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I Want To Make The Background Ambience Sound That Changes When Time Reaches Specfic Time, Like When It Night, The Sound Changes To Night Ambience Sounds.
What is the issue? I Don’t Really Know How To Make It, So I Decide To Make The Script With Intuition, And Yes, It Didn’t Work.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I Looked The DevForum But Not Found Any Topic That Similar To Mine.
local musicbox = game.Workspace.BackgroundSound
local timecycle = game.Lighting.TimeOfDay
if timecycle == "08:00:00" then
musicbox.Sound.SoundId = "rbxassetid://9118752861"
elseif timecycle == "18:00:00" then
musicbox.Sound.SoundId = "rbxassetid://9112836038"
end
musicbox.Sound:Play()
local Lighting = game:GetService("Lighting")
local musicbox = game.Workspace.BackgroundSound
Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
local ClockTime = Lighting.ClockTime
if ClockTime >= 18 or ClockTime >= 0 and ClockTime <= 7 then -- if night
musicbox.Sound.SoundId = "rbxassetid://9112836038"
musicbox.Sound:Play()
else -- if not
musicbox.Sound.SoundId = "rbxassetid://9118752861"
musicbox.Sound:Play()
end
end)
local Lighting = game:GetService("Lighting")
local musicbox = game.Workspace.Folder
musicbox.Sound:Play()
Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
local ClockTime = Lighting.ClockTime
if ClockTime >= 18 or ClockTime >= 0 and ClockTime <= 7 then -- if night
musicbox.Sound.SoundId = "rbxassetid://9112836038"
musicbox.Sound:Play()
elseif ClockTime < 18 or ClockTime > 7 then -- if not
musicbox.Sound.SoundId = "rbxassetid://9118752861"
musicbox.Sound:Play()
end
end)