My random music player is meant to play random music constantly but it only starts to work when a player joins but it doesn't start until the permitted players say the skip command and even then it only plays 1 song once and not again until the skip command is said. Please help me fix this!
----------------------------------------------------------------------------------------------
-- Script Made By UndiscoveredLimited --
-- Put This Script Anywhere --
-- Change The Variable Below's Values --
-- DO NOT LEAVE BLANK SPACES, DELETE THEM --
-- WILL NOT WORK WITH ONLY ONE SONG --
----------------------------------------------------------------------------------------------
SoundIds = {"142397652","154309298","154764197","161006106","144635805"}
Permission = {"UndiscoveredLimited"}
SkipCmd = "skip"
----------------------------------------------------------------------------------------------
for i,v in ipairs(SoundIds) do
game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset?id="..v)
end
Sound = Instance.new("Sound",game.Workspace)
Sound.Volume = 0
Sound.Looped = true
Sound.SoundId = "http://www.roblox.com/asset?id="
Skip = false
function Skip()
Current = SoundIds[math.random(1,#SoundIds)]
Last = Sound.SoundId
wait(4)
Sound.SoundId = "http://www.roblox.com/asset?id="..Current
while Sound.SoundId == Last do
Current = SoundIds[math.random(1,#SoundIds)]
Sound.SoundId = "http://www.roblox.com/asset?id="..Current
end
Sound:Play()
wait(1)
for i = 1,10 do
wait(0.25)
if Sound.Volume ~= 1 then
Sound.Volume = Sound.Volume + 0.1
end
end
wait(110)
for i = 1,10 do
wait(0.25)
if Sound.Volume ~= 0 then
Sound.Volume = Sound.Volume - 0.1
end
end
Sound:Stop()
Skip = false
end
game.Players.ChildAdded:connect(function(Player)
Player.Chatted:connect(function(Chat)
for i = 1, #Permission do
if Player.Name == Permission[i] then
if string.lower(Chat) == SkipCmd then
Sound:Stop()
Skip()
Skip = true
end
end
end
end)
end)
while Skip == false do
Current = SoundIds[math.random(1,#SoundIds)]
Last = Sound.SoundId
wait(4)
Sound.SoundId = "http://www.roblox.com/asset?id="..Current
while Sound.SoundId == Last do
Current = SoundIds[math.random(1,#SoundIds)]
Sound.SoundId = "http://www.roblox.com/asset?id="..Current
end
Sound:Play()
wait(1)
for i = 1,10 do
wait(0.25)
if Sound.Volume ~= 1 then
Sound.Volume = Sound.Volume + 0.1
end
end
wait(110)
for i = 1,10 do
wait(0.25)
if Sound.Volume ~= 0 then
Sound.Volume = Sound.Volume - 0.1
end
end
Sound:Stop()
end
