The only problem is that the sound doesn't change at all.
local function onPlayerEntered(newPlayer) local stats = Instance.new("StringValue") stats.Name = "Area" stats.Value = "Spawn" stats.Parent = newPlayer end function onPlayerRespawned(newPlayer) local stats = newPlayer:FindFirstChild("Area") if stats == nil then local stat = Instance.new("StringValue") stat.Name = "Area" stat.Value = "Spawn" stat.Parent = newPlayer end local song1 = newPlayer.PlayerGui:FindFirstChild("Lobby") if song1 == nil then local song1 = Instance.new("Sound", newPlayer.PlayerGui) song1.Looped = true song1.Name = "Lobby" local Id = "rbxassetid://" song1.SoundId = Id.."319731744" song1.Volume = .5 song1:Play() elseif song1 ~= nil then song1.Looped = true local Id = "rbxassetid://" song1.SoundId = Id.."319731744" song1.Volume = .5 song1:Play() local song2 = newPlayer.PlayerGui:FindFirstChild("Hi") if song2 == nil then local song2 = Instance.new("Sound", newPlayer.PlayerGui) song2.Name = "Hi" song2.Looped = true local Id = "rbxassetid://" song2.SoundId = Id.."319731744" song2.Volume = .5 elseif song2 ~= nil then song2.Looped = true local Id = "rbxassetid://" song2.SoundId = Id.."319731744" song2.Volume = .5 song2:Play() end end local stat = newPlayer:FindFirstChild("Area") local song = newPlayer.PlayerGui:FindFirstChild("Lobby") or newPlayer.PlayerGui:WaitForChild("Lobby") local songtwo = newPlayer.PlayerGui:FindFirstChild("Hi") newPlayer.PlayerGui:WaitForChild("Hi") if stat == nil then local k = Instance.new("StringValue",newPlayer) k.Name = "Area" else stat.Value = "Lobby" songtwo:Stop() song:Play() if stat == nil then local k = Instance.new("StringValue",newPlayer) k.Name = "Area" else stat.Value = "Hi" songtwo:Play() song:Stop() end end end function onPlayerEntered(newPlayer) newPlayer.Changed:connect(function (property) if (property == "Character") then onPlayerRespawned(newPlayer) end end) end game.Players.ChildAdded:connect(onPlayerEntered)
When changing a soundId, you need to stop the music, change the Id, then play it.
Try this
local function onPlayerEntered(newPlayer) local stats = Instance.new("StringValue") stats.Name = "Area" stats.Value = "Spawn" stats.Parent = newPlayer end function onPlayerRespawned(newPlayer) local music = newPlayer:FindFirstChild("Sound") if music == nil then local music = Instance.new("Sound", newPlayer.PlayerGui) music.Looped = true music.SoundId = "http://www.roblox.com/asset/?id=319731744" music.Volume = .5 music:Play() elseif music ~= nil then music.Looped = true music.SoundId = "http://www.roblox.com/asset/?id=319731744" music.Volume = .5 music:Play() end local stat = newPlayer:FindFirstChild("Area") if stat == nil then k = Instance.new("StringValue",newPlayer) k.Name = "Area" else stat.Value = "Lobby" music.SoundId = "http://www.roblox.com/asset/?id=326012211" if stat == nil then k = Instance.new("StringValue",newPlayer) k.Name = "Area" else stat.Value = "Hi" music.SoundId = "http://www.roblox.com/asset/?id=326012211" end end end function onPlayerEntered(newPlayer) newPlayer.Changed:connect(function (property) if (property == "Character") then onPlayerRespawned(newPlayer) end end) end game.Players.ChildAdded:connect(onPlayerEntered)
You just created a localized sound ID but you never told the sound that you wanted it to be that ID so I helped you.