Hi, I’m trying to create a script that checks the TimePosition and TimeLength of a sound, and if they are equal to each other, it will update multiple sounds in a folder to a new SoundId.
However, this doesn’t seem to work for me. The Print(song) command in the script seems to work, as it outputs a new ID every time the while loop is ran, however, the sound simply stops once the end of the song is reached.
The speakers (as found in Workspace):
local songs = {"http://www.roblox.com/asset/?id=xxxxxxx", "http://www.roblox.com/asset/?id=xxxxxxx", "http://www.roblox.com/asset/?id=xxxxxxx", "http://www.roblox.com/asset/?id=xxxxxxx", "http://www.roblox.com/asset/?id=xxxxxxx", "http://www.roblox.com/asset/?id=xxxxxxx", "http://www.roblox.com/asset/?id=xxxxxxx"}
local check = game.Workspace.Speakers.Model.Part
local p = game.Workspace.Speakers:GetChildren()
wait(20)
while true do
local song = songs[math.random(1, #songs)]
print(song)
if check.Sound.TimePosition == check.Sound.TimeLength then
for i,v in pairs(p) do
v.Part.Sound.Playing = false
v.Part.Sound.SoundId = song
v.Part.Sound.Playing = true
end
end
wait(1)
end