Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My Music Will play But it wont play Fully.. Whats the Problem?

Ok I made this script and the music wont play fully.. It just moves on to the next one. Whats the problem.. Heres the script

gw=game.Workspace

function message(text,time)
	local oldmsg=gw:FindFirstChild("Hint")
	if oldmsg then
		oldmsg.Parent=nil
	end
	local spacenumber=time*120
	local msg=Instance.new("Hint")
	msg.Parent=gw


	msg.Text=text
	wait(1)
	msg.Parent=nil
end

last=""
lastlast=""
while true do
	wait(.1)
	local tracks=script:GetChildren()
	local rn=math.random(1,#tracks)
	local track=tracks[rn]
	if track~=nil then
		if track.className=="Sound" and track.Name~=last and track.Name~=lastlast then
			lastlast=last
			last=track.Name
			message(track.Name,5)
			track:play()
			wait(120)
			track:pause()
	end
end

end

2 answers

Not sure, try to see if this works.

print('Music player started!')

local ws = Workspace
local last1 = ""
local last2 = ""

function dispHint(text, len)
	print("Display hint.")
	local ph = ws:GetChildren()
	
	for i = 1, #ph do 
		if ph[i]:IsA("Hint") then ph:Destroy() 
	end end
	
	local holding = (120 * len)
	
	local nh = Instance.new("Hint",Workspace)
	nh.Text = text
	game:GetService("Debris"):AddItem(nh,2)

end

while true do wait()
	print("Running loop.")
	local st = script:GetChildren()
	local rt = math.random(1, #st)
	local ct = st[rt]
	
	if (ct and ct:IsA("Sound") and ct.Name ~= last1 and ct.Name ~= last2) then
		print("Change the track.")
		last2 = last1;
		last = ct.Name
		dispHint("Now playing "..last..".", 5)
		ct:Play()
		wait(120)
		ct:Pause()
	end

end

2 comments

0

Thanks Worked :D

0

Make sure to accept as an answer. :P

1 music? Then put the script in the music.

while true do
script.Parent:Play()
end

This discussion is preserved as it was. New answers, comments, and votes are closed.