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

How to change music on night? [closed]

Asked by 4 years ago

I need night/day change script that changes background music zones! Place: https://www.roblox.com/games/1452770622/Bee-Swarm-Showcase

0
Is... is that a request? SoftlockedUnderZero 668 — 4y
0
um yes imstealingblindness -11 — 4y

Closed as Not Constructive by JakyeRU, ForeverBrown, and hiimgoodpack

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
0
Answered by 4 years ago

If you have a time of day script already implemented, then that's all you really need.

Insert another script into "ServerScriptService" or something like that in the explorer. Then the script would be something like this

TofD = game.Lighting.TimeOfDay -- variables
Sound1 = game.Workspace.Sound
Sound2 = game.Workspace.Sound2 -- You can change sound name in workspace, so it doesn't get cluttered

if TofD == 0 then
    Sound1:Play()
    if TofD == 5 then
        Sound1:Stop()
        Sound2:Play()
    end
end

This is just AN EXAMPLE, since I don't know how you want the code to be. I wouldn't copy the code. I hope this helps in someway as a reference to what you needed.

0
I need to change sound in model imstealingblindness -11 — 4y
0
oh like Workspace.Model.Sound? imstealingblindness -11 — 4y
Ad
Log in to vote
0
Answered by
JakyeRU 637 Moderation Voter
4 years ago

Hello, You can do this by simply adding a GetPropertyChangedSignal event to Lighting and checking the ClockTime.

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
    local Time = game.Lighting.ClockTime

    if Time >= 18 or Time <= 6 then
        print("It's night.")
        -- Your Code Here
    else
        print("It's day.")
        -- Your Code Here
    end
end)

Each time ClockTime is changed, we'll check if the time is greater or equal than 18 or less or equal than 6. If it is true, it's night, if not, it's day.