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

How do I do when a player touches a part cave sounds and nature sounds are gone?

Asked by 2 years ago

Hi there, In my game there is a cave and a forest, I have a script (shown below) that makes day ambience and night ambience, but I don't know how it should work that when the player touches the part he hears cave noises and if he just touches another nature noises again so that he hears completely normal night ambience and day ambience again.

The script i use for the day and night ambience:

local nightSound = game.SoundService.nightSound -- Enter night sound location here
local daySound = game.SoundService.daySound --Enter day sound location here
local CustomMusic = game.SoundService.CustomMusic --Additional Music

while true do
    local Time = game.Lighting.TimeOfDay
    Time = (Time:gsub("[:\r]", ""))
    Time = tonumber(Time)

    if Time >= 180000 or Time < 60000 then
        --Between 1800hrs and 0600hrs


        wait(0.1)
        if daySound.Playing and CustomMusic.Playing then daySound:Stop() moriohSound:Stop() end
        if not nightSound.Playing then
            nightSound:Play()
        end

    else
        --Between 0600 hrs and 1800hrs

        if nightSound.Playing then nightSound:Stop() end
        wait(0.1)
        if not daySound.Playing and not CustomMusic.Playing then
            daySound:Play() 
            CustomMusic:Play()
        end
    end
end

Answer this question