Song Player not working

Hey Everyone
I’m making a song player for my game, but it’s not working!
Here is my script:

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Events = ReplicatedStorage:WaitForChild('Events')

Events.GetRandomSong.Event:Connect(function()
	SongThatWillBePlayed = game.ReplicatedStorage.LobbyMusic:GetChildren()[math.random(1,#game.ReplicatedStorage.LobbyMusic:GetChildren())]
end)

Events.PlaySong.Event:Connect(function()
	SongThatWillBePlayed:Play()
	print('Playing song...')
	SongThatWillBePlayed.Looped = true
end)

Events.StopSong.Event:Connect(function()
	SongThatWillBePlayed.Looped = false
	SongThatWillBePlayed:Stop()
end)

I get no errors, Playing song… prints, but the song doesn’t play
Thanks for any help!

The problem is that you are playing the instance while it is in ReplicatedStorage. You need to move the sound outside of ReplicatedStorage and put it in a service where sounds play, such as Workspace.

3 Likes