How do I randomize this professionally, I wanna make it so it randomizes from songs, but doesn’t pkay the last song that just played earlier, when it randomized, and it won’t play any other random song that just played, until the whole list has been played, then it loops.
Here’s the script:
local S2 = script.Parent.S2
local S3 = script.Parent.S3
local S4 = script.Parent.S4
local S5 = script.Parent.S5
local S6 = script.Parent.S6
local S7 = script.Parent.S7
local S8 = script.Parent.S8
local S9 = script.Parent.S9
local S10 = script.Parent.S10
local S11 = script.Parent.S11
local S12 = script.Parent.S12
local S13 = script.Parent.S13
local S14 = script.Parent.S14
local S15 = script.Parent.S15
local S16 = script.Parent.S16
local S17 = script.Parent.S17
local S18 = script.Parent.S18
local S19 = script.Parent.S19
local S20 = script.Parent.S20
local S21 = script.Parent.S21
local S22 = script.Parent.S22
local S23 = script.Parent.S23
local S24 = script.Parent.S24
local S25 = script.Parent.S25
local currentTrack = workspace.Songs.CurrentTrack
-------------------------------------------------
while true do
S1:Play()
currentTrack.Value = "Sub Zero - Lil Uzi Vert"
wait(120.084)
S1:Stop()
S2:Play()
currentTrack.Value = "Instant Friend - Fetty Wap"
wait(200.208)
S2:Stop()
S3:Play()
currentTrack.Value = "Slow Motion - Trey Songz"
wait(120.216)
S3:Stop()
S4:Play()
currentTrack.Value = "Just For The Night - Chris Brown, Migos"
wait(80.169)
S4:Stop()
S5:Play()
currentTrack.Value = "Smile - Chris Brown"
wait(161.376)
S5:Stop()
S6:Play()
currentTrack.Value = "Jocelyn Flores - XXXtentaction"
wait(117.472)
S6:Stop()
S7:Play()
currentTrack.Value = "Unforgetful - Tory Lanez"
wait(79.882)
S7:Stop()
S8:Play()
currentTrack.Value = "I just want it all - Kid Ink"
wait(119.902)
S8:Stop()
S9:Play()
currentTrack.Value = "Homies - Arizona Zervas"
wait(220.368)
S9:Stop()
S10:Play()
currentTrack.Value = "Hotel - Kid Ink"
wait(327.512)
S10:Stop()
S11:Play()
currentTrack.Value = "Say it - Tory Lanez"
wait(40.254)
S11:Stop()
S12:Play()
currentTrack.Value = "Be Real - Kid Ink"
wait(170.352)
S12:Stop()
S13:Play()
currentTrack.Value = "Time - Tory Lanez"
wait(80.065)
S13:Stop()
S14:Play()
currentTrack.Value = "I like me better - Lauv"
wait(105.351)
S14:Stop()
S15:Play()
currentTrack.Value = "Lens V2 - Travis Scott"
wait(379.637)
S15:Stop()
S16:Play()
currentTrack.Value = "Cooler than me - Mike Posner"
wait(116.453)
S16:Stop()
S17:Play()
currentTrack.Value = "G.O.A.T - Eric Bellinger"
wait(50.05)
S17:Stop()
S18:Play()
currentTrack.Value = "Get on your knees - Ariana Grande, Nicki Minaj"
wait(216.648)
S18:Stop()
S19:Play()
currentTrack.Value = "These Days - Mike Stud"
wait(117,08)
S19:Stop()
S20:Play()
currentTrack.Value = "City of Roses"
wait(120.032)
S20:Stop()
S21:Play()
currentTrack.Value = "Blur - Stellar"
wait(131.526)
S21:Stop()
S22:Play()
currentTrack.Value = "One Last Time - Ariana Grande"
wait(247.066)
S22:Stop()
S23:Play()
currentTrack.Value = "Heart On Ice - Rod Wave"
wait(89.469)
S23:Stop()
S24:Play()
currentTrack.Value = "Hate the other side - Juice Wrld"
wait(150.12)
S24:Stop()
S25:Play()
currentTrack.Value = "Angels and Demons - Jxden"
wait(119.353)
S25:Stop()
--Want more songs? Read the READ_ME script and put the S7 step below me!
end
You’ll have to create a separate array to store the id’s of the songs that haven’t been played and loop through them. Then, you simply pick a random index with math.random(1, #tableNameHere), play the song and remove it from the array. Repeat this process until you have no values left, to where you can just restart the loop.
use a for loop and your math.random to choose a random song but if you want them to be in an order then use a table containing all song id in an orderly way then for loop and change the song
I gave you a pretty detailed step by step answer, if you can’t do it then that’s just a matter of you not understanding how to program, and since this is scripting support and not scripting requests I can’t exactly do it for you.
No- I’m just asking like, what would I first do would I put math.random(1, #tableNameHere) on the top, and then “math.random(1, #tableNameHere)” on every song sentence, and then play?
local CurrentTrack = workspace.Songs.CurrentTrack
local CurrentSong = nil
local Songs = {}
function RNG(Min, Max)
return Random.new():NextInteger(Min, Max)
end
for _, Value in ipairs(script.Parent:GetChildren()) do
if Value:IsA("Sound") then
table.insert(Songs, Value)
end
end
while true do
local Song = Songs[RNG(1, #Songs)]
repeat task.wait()
Song = Songs[RNG(1, #Songs)]
until CurrentSong.Name ~= Song.Name
Song:Play()
CurrentTrack.Value = Song.Name
Song.Ended:Wait()
end
this is how I would do it
you need to name the song instances to the name of the song
k so look, I have the table, but- I don’t want it to check workspace, I want it to go off the table list of when I have for example this is all just 1 table, I don’t want it to do song.Ended, I want it to randomize off the tables of that line off that script, and then it removes it from the table so it won’t play again, and once every song played, table restarts, all I need help on is how do I put the tables into that line of script, and have it randomize then besides workspace, basically I want it all to randomize in that script if you get what I mean?
S4:Play()
currentTrack.Value = “Just For The Night - Chris Brown, Migos”
wait(80.169)
S4:Stop()
local currentTrack = workspace.Songs.CurrentTrack
local songList = {}
for index, song in ipairs(LobbyMusic:GetChildren()) do
table.insert(songList,index,song)
end
while true do
local randSong = songList[math.random(1,#songList)]
randSong:Play()
randSong.Ended(wait())
table.remove(songList.table.find(songList,randSong))
end
-------------------------------------------------
local songs = {}
while true do
S1:Play()
currentTrack.Value = "Sub Zero - Lil Uzi Vert"
wait(120.084)
S1:Stop()
S2:Play()
currentTrack.Value = "Instant Friend - Fetty Wap"
wait(200.208)
S2:Stop()
S3:Play()
currentTrack.Value = "Slow Motion - Trey Songz"
wait(120.216)
S3:Stop()
S4:Play()
currentTrack.Value = "Just For The Night - Chris Brown, Migos"
wait(80.169)
S4:Stop()
S5:Play()
currentTrack.Value = "Smile - Chris Brown"
wait(161.376)
S5:Stop()
S6:Play()
currentTrack.Value = "Jocelyn Flores - XXXtentaction"
wait(117.472)
S6:Stop()
S7:Play()
currentTrack.Value = "Unforgetful - Tory Lanez"
wait(79.882)
S7:Stop()
S8:Play()
currentTrack.Value = "I just want it all - Kid Ink"
wait(119.902)
S8:Stop()
S9:Play()
currentTrack.Value = "Homies - Arizona Zervas"
wait(220.368)
S9:Stop()
S10:Play()
currentTrack.Value = "Hotel - Kid Ink"
wait(327.512)
S10:Stop()
S11:Play()
currentTrack.Value = "Say it - Tory Lanez"
wait(40.254)
S11:Stop()
S12:Play()
currentTrack.Value = "Be Real - Kid Ink"
wait(170.352)
S12:Stop()
S13:Play()
currentTrack.Value = "Time - Tory Lanez"
wait(80.065)
S13:Stop()
S14:Play()
currentTrack.Value = "I like me better - Lauv"
wait(105.351)
S14:Stop()
S15:Play()
currentTrack.Value = "Lens V2 - Travis Scott"
wait(379.637)
S15:Stop()
S16:Play()
currentTrack.Value = "Cooler than me - Mike Posner"
wait(116.453)
S16:Stop()
S17:Play()
currentTrack.Value = "G.O.A.T - Eric Bellinger"
wait(50.05)
S17:Stop()
S18:Play()
currentTrack.Value = "Get on your knees - Ariana Grande, Nicki Minaj"
wait(216.648)
S18:Stop()
S19:Play()
currentTrack.Value = "These Days - Mike Stud"
wait(117,08)
S19:Stop()
S20:Play()
currentTrack.Value = "City of Roses"
wait(120.032)
S20:Stop()
S21:Play()
currentTrack.Value = "Blur - Stellar"
wait(131.526)
S21:Stop()
S22:Play()
currentTrack.Value = "One Last Time - Ariana Grande"
wait(247.066)
S22:Stop()
S23:Play()
currentTrack.Value = "Heart On Ice - Rod Wave"
wait(89.469)
S23:Stop()
S24:Play()
currentTrack.Value = "Hate the other side - Juice Wrld"
wait(150.12)
S24:Stop()
S25:Play()
currentTrack.Value = "Angels and Demons - Jxden"
wait(119.353)
S25:Stop()
--Want more songs? Read the READ_ME script and put the S7 step below me!
end
local CurrentTrack = workspace.Songs.CurrentTrack
local CurrentSong = nil
local Songs = {}
function RNG(Min, Max)
return Random.new():NextInteger(Min, Max)
end
for _, Value in ipairs(script.Parent:GetChildren()) do
if Value:IsA("Sound") then
table.insert(Songs, Value)
end
end
while true do
local Song = Songs[RNG(1, #Songs)]
repeat task.wait()
Song = Songs[RNG(1, #Songs)]
until CurrentSong.Name ~= Song.Name
Song:Play()
CurrentTrack.Value = Song.Name
task.wait(RNG(0, Sound.TimeLength))
Song:Stop()
end
does this work for you?
it would wait a random amount of time based on how long the time is