I am attempting to make a simple song request system. the system I have now simply plays default music until somebody suggests something different. The default sounds plays correctly the first time but when it comes around to play it again the audio doesnt play at all. The playing boolean value is true however and even the UI changes accordingly with my remote event but the audio is not making any noise. I put print statements inside the function itself and it even prints it accordingly.
local function playMusic(song)
game.ReplicatedStorage.Sounds.Music.SoundId = "rbxassetid://"..song.SongId
if game.ReplicatedStorage.Sounds.Music.IsLoaded == false then
game.ReplicatedStorage.Sounds.Music.Loaded:Wait()
end
game.ReplicatedStorage.Sounds.Music:Play()
RemoteEvents.NowPlaying:FireAllClients(song.SongName)
wait(game.ReplicatedStorage.Sounds.Music.TimeLength)
end
while true do
for _,song in ipairs(defaultPlaylist) do
if #queuedSongs <= 0 then
playMusic(song)
else
print("playing queued")
playMusic(queuedSongs[1])
table.remove(queuedSongs, 1)
end
end
game:GetService("RunService").Heartbeat:Wait()
end
end)()
local function playMusic(song)
game.ReplicatedStorage.Sounds.Music.SoundId = "rbxassetid://"..song.SongId
if game.ReplicatedStorage.Sounds.Music.IsLoaded == false then
game.ReplicatedStorage.Sounds.Music.Loaded:Wait()
end
local Yes, No = pcall(function()
game.ReplicatedStorage.Sounds.Music.IsPlaying = true
end)
if Yes then
print("The sound should be playing fine?")
else
warn(No)
end
RemoteEvents.NowPlaying:FireAllClients(song.SongName)
wait(game.ReplicatedStorage.Sounds.Music.TimeLength)
end
Well idk what else could be the potential issue for this then
The only other thing is that I do recall some certain Sounds not being able to be played again when upon selected, but it seems to be a rare occurrence from the posts made by the Forum
This is probably the most relevant thing I could find, other than that I have nothing else to say
An alternate could be to use SoundService’s PlayLocalSound on the client instead of playing it on the server perhaps?