i’m trying to make it so when the sound ends, it activates the function playsound() again, so music can loop. But by using the property Sound.Ended:Wait() it seems like it does nothing because after testing, it doesn’t print anything or play the other track.
local rp = game:GetService("ReplicatedStorage")
local MusicFolder = rp:FindFirstChild("Music")
print("Loaded")
local Musics = MusicFolder:GetChildren()
function playmusic()
local playone = math.random(1,#Musics)
print(playone)
MusicFolder[playone]:Play()
MusicFolder[playone].Ended:Wait()
print("ended")
playmusic()
end
playmusic()
I would do that, but the game i’m making contains super powers like Freezing Time, in which the songs that are playing, stop. Therefore i want the whole track to play and not end abruptly.
*The sound is only being played by the script.
*The sound is not Looped
*The sound stops, but then resumes once time has resumed (read the previous response).
local rp = game:GetService("ReplicatedStorage")
local MusicFolder = rp:FindFirstChild("Music")
print("opa bohne")
local Musics = MusicFolder:GetChildren()
function playmusic()
local playone = math.random(1,#Musics)
print(playone)
MusicFolder[playone]:Play()
MusicFolder[playone].Stopped:Connect(function()
print("Music has ended.")
playmusic()
end)
end
playmusic()
I’m telling you, i can’t do this because players can freeze time ingame which also pauses the music, which after time has resumes it plays the music again, then causing it to end abruptly.
If they control time in game, make the script get a remote event, and then the remote event waits however long it lasts for then plays it again / unpauses it.
The problem doesn’t occur when it stops, or resumes time by itself, it occurs that even when Time is stopped the wait() is still on course, say the player stops time for 15 seconds, and the song is 30 seconds long, then it will only play 15 seconds of the song. Do you understand now?