Music Playing script not working anymore, multiple errors

You can also do

local s, e = pcall(Functionname())
if not s then warn(e) return end

I wanted to test all of the code.

Oh, I can do that too, lemme try.


Now I’m beyond confused, because the text is still ā€œNothingā€, but it plays, and the skip button doesn’t work. Check the output window.

Here’s the full script now I guess, because this is really starting to confuse me.

local succ, err = pcall(function()
	--Overcomplexified playing script, 2021 DarkPixlz
	local Player = game.Players.LocalPlayer
	local availableMusic = game.ReplicatedStorage:WaitForChild("Music"):GetChildren() 
	local PlayingTrack 
	local PlayingUI = Player.PlayerGui:WaitForChild("NowPlaying").Frame
	local SkipBTN = PlayingUI.skip
	local MuteBTN = PlayingUI.Mute
	local DefaultVol = 5
	local Volume = Player:GetAttribute("Volume")
	local MusicVol = 0
	local Count = 0 
	local DB = false
	local NextVolume = DefaultVol
	local SecretChance = math.random(1,999999)
	local db2 = false
	local playing
	local PlayingSong = nil
	local randomTrack = nil
	local function Play()
		if not Player:GetAttribute("PlayMusic") then return end 
		if Player:GetAttribute("PlayMusic") == false then return end
		if PlayingTrack then PlayingTrack:Stop() end
		randomTrack = availableMusic[math.random(1,#availableMusic)]
		if SecretChance == 472793 then
			local availablesecrets = game.ReplicatedStorage.SecretSongs:GetChildren()
			local randsecret = availablesecrets[math.random(1,#availablesecrets)]
			randomTrack = randsecret
		end
		Player:SetAttribute("CurrentTrack",randomTrack.Name)
		--	if randomTrack.Name == "SecretSongs" then randomTrack = availableMusic[math.random(1,#availableMusic)] return end
		PlayingTrack = randomTrack
		PlayingTrack.Volume = NextVolume
		randomTrack:Play() 
		PlayingUI.Parent.ea.name.Text = randomTrack.Name
		playing = true
		PlayingSong = PlayingTrack
		--print ("Playing", randomTrack.Name)
		SecretChance = math.random(1,999999)
		while playing == true do
			PlayingUI.Parent.ea.time.Text = math.round(PlayingTrack.TimePosition).."/"..math.round(PlayingTrack.TimeLength)
			PlayingUI.time.Text = math.round(PlayingTrack.TimePosition).."/"..math.round(PlayingTrack.TimeLength)
			task.wait()
		end
	end
	Player:GetAttributeChangedSignal("PlayMusic"):Connect(function()
		Play()
	end)
	local function ToggleMusic()
		if Player:GetAttribute("PlayMusic") then
			Player:SetAttribute("PlayMusic",false)
		else
			Player:SetAttribute("PlayMusic",true)
		end
	end
	repeat task.wait() until randomTrack ~= nil
	print("RandonTrack is no longer nil!")
	print("Calling tweens..")
	randomTrack.Ended:Connect(function()
		PlayingUI.Parent.ea:TweenPosition(UDim2.new(-0.009, 0, .723, 0), "In", "Quint", 1.5, true)
		Play()
		task.wait(5)
		PlayingUI.Parent.ea:TweenPosition(UDim2.new(-.233, 0, .723, 0), "In", "Quart", 1, true)
	end)
	PlayingUI.Parent.ea.OpenHitbox.MouseEnter:Connect(function()
		PlayingUI.Parent.ea:TweenPosition(UDim2.new(-0.111, 0, .723, 0), "Out", "Quart", 1, true)
	end)
	PlayingUI.Parent.ea.OpenHitbox.MouseLeave:Connect(function()
		PlayingUI.Parent.ea:TweenPosition(UDim2.new(-.233, 0, .723, 0), "In", "Quart", 1, true)
	end)
	PlayingUI.Parent.ea.OpenHitbox.MouseButton1Click:Connect(function()
		PlayingUI.Parent.ea:TweenPosition(UDim2.new(-.233, 0, .723, 0), "In", "Quart", 1, true)
		PlayingUI:TweenPosition(UDim2.new(0.292, 0, 0.238, 0), "In", "Quart", 1, true)
	end)
	PlayingUI.TextButton.MouseButton1Click:Connect(function()
		PlayingUI:TweenPosition(UDim2.new(-0.5, 0, 0.238, 0), "In", "Quart", 1, true)
	end)
	print("Nothing went wrong with calling the tweens.")
	local function MuteMusic(bool)
		PlayingTrack.Volume = bool and 0 or DefaultVol
		if PlayingTrack.Volume == 0 then NextVolume = 0 elseif PlayingTrack.Volume == DefaultVol then NextVolume = DefaultVol elseif PlayingTrack.Volume == bool then NextVolume = bool end
	end
	print("Made it to line 80_MUSIC")
	local function SkipMusic()
		if not Player:GetAttribute("PlayMusic") then 
			return 
		end
		PlayingTrack.TimePosition = PlayingTrack.TimeLength - 1
		task.wait(5)
		PlayingUI.Parent.ea:TweenPosition(UDim2.new(-.233, 0, .723, 0), "Out", "Quint", 1.5, true) --{-0.233, 0},{0.723, 0}
		print ("Skipped!")
		task.wait(0.5)
	end
	--PlayNexTrack()
	local db = false
	Player:SetAttribute("CurrentTrack","...")
	Player:SetAttribute("PlayMusic",false)
	MuteBTN.MouseButton1Click:Connect(function()
		MuteMusic(PlayingTrack.Volume == DefaultVol)
	end)

	SkipBTN.MouseButton1Click:Connect(function()
		SkipMusic()
		task.wait(1)
	end)

	PlayingUI.Pause.MouseButton1Click:Connect(function()
		if PlayingSong.Playing == true then
			PlayingSong:Pause()
		else
			PlayingSong:Resume()
		end
	end)

	Player:GetAttributeChangedSignal("Volume"):Connect(function()
		PlayingTrack.Volume = Player:GetAttribute("Volume").Value
		MusicVol = Player:GetAttribute("Volume").Value
	end)
end)

if not succ then warn("Error with music!!! Error: "..err) else print("Everything went right..?") end
  • Hmm, this is incredibly strange…
    If you want, I can recode this for you and send you my version of this. I sadly, can’t see exactly what the issue was with this. Since again, It is not my code…
1 Like

Go ahead if you want…

If you want, you can send me the UI so I can make it match as much as possible.

  • Feel free to privately DM me, if need be.
1 Like