Sometimes when the song is supposed to change, the song just doesnt play. I am assuming this is from return function() and it tries to repeat the same song but I really dont know why it stops playing.
Music.Ended:Connect(function()
VoteReady.Value = false
wait(1)
local Song = math.random(1,NumberOfSongs)
local SongChosen = Songs:FindFirstChild(Song)
if SongChosen then
if SongChosen.Value == LastSong.Value then
return function()
end
else
Music.SoundId = "rbxassetid://"..SongChosen.Value
LastSong.Value = SongChosen.Value
local SongNameFound = SongNames:FindFirstChild(Song)
if SongNameFound then
SongName.Value = SongNameFound.Value
else
warn("Song name not found!")
end
Music.TimePosition = 0
Music:Play()
VoteReady.Value = true
end
else
warn("Song not found!")
return function()
end
end
end)

3 comments
sorry forgot to add that part
I don't know why listeners are returning a value here? roblox does not expect anything back from them, and why are you returning a function. When a return statement is reached, the function ends, so if line 8-9 is reached, everything else under it will not execute
idk, I mean i am try to make it so the if the script tries to play the same song again it redoes the function until it picks a diff song