Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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

Log in to vote
1
Answered by
Dummiez 360 Moderation Voter
10 years ago

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
0
Thanks Worked :D MicrobeBlox 5 — 10y
0
Make sure to accept as an answer. :P Dummiez 360 — 10y
Ad
Log in to vote
1
Answered by 10 years ago

1 music? Then put the script in the music.

while true do
script.Parent:Play()
end

Answer this question