Hello everyone,
I am trying to make a audio player (Server sided), but I cant seem to get it to work.
Below is my code
songtable = {7698151169,5140419602,465694735,859998992,402306149,5926165880,658515091,1125114380,1436433218}
customsongtable = {}
game.ReplicatedStorage.ClientEvents.CustomSongEvent.OnServerEvent:Connect(function(player,idofsong)
table.insert(customsongtable,idofsong)
end)
while true do
if #customsongtable == 0 then
local randosong = math.random(1,9)
game.Workspace.MainSound.SoundId = "rbxassetid://" .. songtable[randosong]
game.Workspace.MainSound.TimePosition = 0
game.Workspace.MainSound.Playing = true
game.Workspace.MainSound.Ended:Wait()
else
game.Workspace.MainSound.SoundId = "rbxassetid://" .. customsongtable[1]
game.Workspace.MainSound.TimePosition = 0
game.Workspace.MainSound.Playing = true
table.remove(customsongtable[1])
game.Workspace.MainSound.Ended:Wait()
end
end
The the problem is even when the #customsongtable is empty, the random song loops only once then stops and doesn’t play any songs anymore.
And for custom songs when I try to insert a sound ID to the table the sound turns out to be a simple “-” even when I know it should come back as a song ID which I have put in through a text box from client.
Please correct me if I am doing something wrong anywhere.