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

How do i Fix This is Background Music script?

Asked by 4 years ago

This script turns off the music when it dies, but the music doesn't continue on respawn please tell me how to fix this

local plr = game.Players.LocalPlayer

local bgm = game.Lighting:WaitForChild("bgm")

local m

local head = {}

plr.CharacterAdded:Connect(function(chr)
    m = Instance.new("Sound", chr)
    head[1] = chr:WaitForChild("Head")
    while plr.Character do
        wait(.4)
        for i , v in pairs(bgm:GetChildren())do
            local region = Region3.new(v.Position - (v.Size/2), v.Position + (v.Size/2))
            local found = game.Workspace:FindPartsInRegion3WithWhiteList(region, head)
            if found[1] then
                local s = v:FindFirstChildOfClass("Sound")
                if s and s.SoundId ~= m.SoundId then
                    m:Stop()
                    m.SoundId = s.SoundId
                    m:Play()
                end
                break
            elseif i == #bgm:GetChildren() and m.IsPlaying then
                local vol = m.Volume
                for i=4, 0, -1 do
                    m.Volume = vol*(i/5)
                    wait(.5)
                end
                m:Stop()
                m.SoundId = ""
                m.Volume = vol
            end
        end
    end
end)
0
Have you tried to change the TimePosition to 0 upon respawn? RazzyPlayz 497 — 4y
0
no Green_SteveYT 8 — 4y
0
Why are you playing it on a character's head? I suggest placing the sound in Workspace instead. If you want it to turn off for one player, place it in a players PlayerGui, since that's local Sus4noREMASTEREDv3 1 — 4y

Answer this question