So I got a music script and for some reason when I change wait(120) to wait(songs.TimeLength) the song plays, and stops on the same song. Here’s the script below
local songs = { --songid, name
{290176752, "Yeah Yeah Yeahs - Heads Will Roll (JVH-C remix)"},
{3314604270, "bbno$ & y2k - lalala"},
{603146550, "Cartoon - On & On"},
{674678896, "The Chainsmokers - Paris (Launchpad Remix)"},
{473760808, "Alex Skrindo - Jumbo"},
{678878009, "Bones - TakingOutTheTrash"},
{2642540349, "Halogen - U Got That"},
{2513053758, "Halsey - Without me"},
{647317220, "Lukas Graham - 7 Years [Owen Remix]"},
}
local nowplaying = {}
local requests = {
}
function shuffleTable(t)
math.randomseed(tick())
assert(t, "shuffleTable() expected a table, got nil" )
local iterations = #t
local j
for i = iterations, 2, -1 do
j = math.random(i)
t[i], t[j] = t[j], t[i]
end
end
shuffleTable(songs)
local songnum = 0
function game.ReplicatedStorage.musicEvents.getSong.OnServerInvoke()
return nowplaying
end
game.ReplicatedStorage.musicEvents.purchaseSong.OnServerEvent:connect(function(p)
if p.userId > 0 then
game:GetService("MarketplaceService"):PromptProductPurchase(p, productId)
end
end)
local votes = {
}
function makesong()
workspace:WaitForChild("TrelloSound"):Stop()
wait()
if #requests == 0 then
songnum = songnum+1
if songnum > #songs then
songnum = 1
end
nowplaying = songs[songnum]
else
nowplaying = requests[1]
table.remove(requests,1)
end
local thisfunctionssong = nowplaying[1]
workspace.TrelloSound.SoundId = "rbxassetid://"..thisfunctionssong
wait()
workspace.TrelloSound:Play()
game.ReplicatedStorage.musicEvents.newSong:FireAllClients(nowplaying)
votes = {}
wait(songs.TimeLength)
if "rbxassetid://"..nowplaying[1] == "rbxassetid://"..thisfunctionssong then
makesong()
end
end
function countVotes()
local c = 0
for _,v in pairs(votes) do
if v[2] == true then
c = c +1
end
end
local remainder = #game.Players:GetPlayers() - #votes
print(remainder)
print(#votes)
local percent = (c + (remainder/2))/#game.Players:GetPlayers()
game.ReplicatedStorage.musicEvents.voteChange:FireAllClients(percent)
if percent <= 0.2 then
--skip song
makesong()
end
return
end
game.ReplicatedStorage.musicEvents.voteYes.OnServerEvent:connect(function(p)
for _,v in pairs(votes) do
if v[1] == p.Name then
v[2] = true
countVotes()
return
end
end
table.insert(votes, {p.Name, true})
countVotes()
end)
game.ReplicatedStorage.musicEvents.voteNo.OnServerEvent:connect(function(p)
for _,v in pairs(votes) do
if v[1] == p.Name then
v[2] = false
countVotes()
return
end
end
table.insert(votes, {p.Name, false})
countVotes()
end)
--skip song command
Group = 2888962
RequiredRank = 14
game.Players.PlayerAdded:connect(function(Player)
Player.Chatted:connect(function(msg)
if Player:GetRankInGroup(Group) >= RequiredRank or Player.Name == "Player" or Player.Name == "Crossota" or Player.Name == "TimeFailured" or Player.Name == "railworks2" or Player.Name == "ExploreTheLocal" then
if msg == 'skipsong'or msg == 'SkipSong' then
makesong()
end
end
end)
end)
game:GetService('MarketplaceService').ProcessReceipt = function(details)
for _, player in ipairs(game.Players:GetPlayers()) do
if player.userId == details.PlayerId then
if details.ProductId == productId then
game.ReplicatedStorage.musicEvents.addSong:FireClient(player)
end
end
end
end
game.ReplicatedStorage.musicEvents.addSong.OnServerEvent:connect(function(p,id)
if tonumber(id) ~= nil and game:GetService("MarketplaceService"):GetProductInfo(tonumber(id)).AssetTypeId == 3 then
table.insert(requests, {tonumber(id), game:GetService("MarketplaceService"):GetProductInfo(tonumber(id)).Name})
end
end)
makesong()
Can someone help me I don’t know if I am missing something to that or not.