So I've already asked to help with this script before, but now there is 1 problem. It works in studio, but it glitches the freak out in a real server. This is the script:
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
local player = script.Parent.Parent.Parent.Parent
local M = script.Parent
local listbkg = M.ListBkg
local stopp = M.StopPic
local stop = M.Stop
local repb = M.Repeat
local repp = M.RepeatPic
local musicl = M.MusicList
local next = M.Next
local less = M.Less
local more = M.More
local drag = M.Dragger
local dragtext = M.DragText
local musiclist = {}
local musicmodel = script.Parent.Parent.Music
local music = musicmodel:children()
for i,v in pairs(music) do
v.Looped = false
v.PlayOnRemove = false
table.insert(musiclist,v:clone())
end
musicmodel:remove()
local musiclistbuttons = {}
for i,v in pairs(musiclist) do
local ng = Instance.new("TextButton",M)
ng.Position = UDim2.new(0, 0, 0, 20) + UDim2.new(0,0,0,13*i)
ng.Size = UDim2.new(0, 200, 0, 13)
ng.BackgroundTransparency = 1
ng.BackgroundColor3 = Color3.new(0/255,0/255,0/255)
ng.BorderColor3 = Color3.new(255/255,255/255,255/255)
ng.TextColor3 = Color3.new(255/255,255/255,255/255)
ng.Font = "ArialBold"
ng.FontSize = "Size10"
ng.Visible = false
ng.Text = v.Name
ng.Name = v.Name
table.insert(musiclistbuttons,i,ng)
ng.MouseButton1Click:connect(function()
if ng.BackgroundTransparency == 1 then
changesong(musiclist[i])
end
end)
end
listbkg.Size = UDim2.new(0, 120, 0, 20) + UDim2.new(0,0,0,13*#musiclistbuttons)
-----------------------------------------------
-----------------------------------------------
local currentsong = musiclist[1]:clone()
local rep = false
local open = false
local playing = true
local beingdragged = false
local X = M.Position.X.Offset
local Y = M.Position.Y.Offset
local XS = M.Position.X.Scale
local YS = M.Position.Y.Scale
--player.CharacterAdded:wait()
drag.MouseButton1Down:connect(function(mx,my)
beingdragged = true
X = M.Position.X.Offset
Y = M.Position.Y.Offset
XS = M.Position.X.Scale
YS = M.Position.Y.Scale
DposX=mx-X
DposY=my-Y
end)
drag.MouseMoved:connect(function(mx,my)
if beingdragged then
print("Moving")
M.Position=UDim2.new(XS,mx - DposX,YS,my - DposY)
if script.Parent.ColG.Text ~= "Disco Hangout[1.2]" then M:remove() end
end
end)
drag.MouseButton1Up:connect(function()
beingdragged = false
print("Mouse going up")
if script.Parent.ColG.Text ~= "Disco Hangout[1.2]" then M:remove() end
end)
drag.MouseLeave:connect(function()
beingdragged = false
dragtext.Visible = false
print("Mouse left")
if script.Parent.ColG.Text ~= "Disco Hangout[1.2]" then M:remove() end
end)
drag.MouseEnter:connect(function()
dragtext.Visible = true
end)
function checkforstop(song)
while currentsong.IsPlaying do
wait(1)
end
end
function playsong()
checkforstop(currentsong)
print("song stopped")
if playing then
if rep then
currentsong:play()
playsong(currentsong)
else
for i,v in pairs(musiclist) do
if currentsong.Name == v.Name then
if i == #musiclist then
changesong(musiclist[1])
else
if script.Parent.ColG.Text ~= "Disco Hangout[1.2]" then M:remove() end
changesong(musiclist[i+1])
end
end
end
end
end
end
function changesong(song)
for i,v in pairs(musiclistbuttons) do
if song.Name ~= v.Name then
v.BackgroundTransparency = 1
if script.Parent.ColG.Text ~= "Disco Hangout[1.2]" then M:remove() end
else
v.BackgroundTransparency = 0
end
end
currentsong:stop()
currentsong:remove()
currentsong = song:clone()
currentsong.Parent = M
if playing then
currentsong:play()
playsong(currentsong)
end
end
stop.MouseButton1Click:connect(function()
if playing then
playing = false
stopp.Style = "ChatGreen"
stop.Text = "Play"
currentsong:stop()
else
stopp.Style = "ChatRed"
if script.Parent.ColG.Text ~= "Disco Hangout[1.2]" then M:remove() end
stop.Text = "Stop"
playing = true
currentsong:play()
playsong(currentsong)
end
end)
musicl.MouseButton1Click:connect(function()
for _,v in pairs(musiclistbuttons) do
v.Visible = not v.Visible
end
listbkg.Visible = not listbkg.Visible
end)
repb.MouseButton1Click:connect(function()
repp.Visible = not repp.Visible
rep = not rep
if script.Parent.ColG.Text ~= "Disco Hangout[1.2]" then M:remove() end
end)
next.MouseButton1Click:connect(function()
for i,v in pairs(musiclist) do
if currentsong.Name == v.Name then
if i == #musiclist then
changesong(musiclist[1])
else
changesong(musiclist[i+1])
end
end
end
end)
less.MouseButton1Click:connect(function()
for _,v in pairs(musiclist) do
if v.Volume >.1 then
v.Volume = v.Volume -.1
end
end
if currentsong.Volume >.1 then
currentsong.Volume = currentsong.Volume -.1
end
end)
more.MouseButton1Click:connect(function()
for _,v in pairs(musiclist) do
if v.Volume <1.2 then
v.Volume = v.Volume +.1
end
end
if currentsong.Volume <1.2 then
currentsong.Volume = currentsong.Volume +.1
end
end)
currentsong.Parent = M
currentsong:play()
musiclistbuttons[1].BackgroundTransparency = 0
playsong(currentsong)
PLEASE HELP ME! THANKS! I will even give 50 robux to the person who helps as gratitude!

11 comments
This: Players.Player1.PlayerGui.Music Player (Place in StarterGui:134: attempt to index local 'song' (a nil value)
what is the script supposed to be for?
Its for a gui music player!
Try changing the location of the GUI and script to the starter GUI and make sure your script is a local script.
I did. XD
Its actually working on studio now its not working properly in the server.
check the developer console in game so you can see what is failing
Ok.
It doesn't say anything. But this is what happens: It keeps playing the song and then plays the next song. If you want to see what happens, join my game
FIXED IT! YEAH BUDDY! ADDED WAIT TIME FOR REMOVAL :D
Glad I could be of assistance..