#How do i make this mute the playlist when entered

7 messages · Page 1 of 1 (latest)

fallen trellis
#

So when i enter the shop, i want the regular background audio to mute, and when you leave, i want it to continue. How do i do this?

local AreaSounds = Instance.new("Sound", script)
AreaSounds.Looped = true
local plr = script.Parent
local Presser = plr:WaitForChild("HumanoidRootPart")
local DifferentAreas = workspace:WaitForChild("Areas")
local CurrentArea = nil

game:GetService("RunService").Heartbeat:Connect(function()
local raycast = Ray.new(Presser.Position, Presser.CFrame.UpVector * -1000)
local part = workspace:FindPartOnRayWithWhitelist(raycast, {DifferentAreas})
if part and part.Parent == DifferentAreas then
if part ~= CurrentArea then

        CurrentArea = part
        AreaSounds.SoundId = CurrentArea.Sound.SoundId
        AreaSounds:Play()
    end 
else
    CurrentArea = nil
    AreaSounds:Stop()
end

end)

strong plank
#

Since you’re teleported into the room why not just put an invisible part which uses a touched event? This would make it simple. When the player teleports back out use another part to detect when they leave the room.

tawny temple
#

since you already know when they teleport

fallen trellis
#

roblox doesnt record with audio

calm vapor
#

why cant you just turn down the background music volume?