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

What is wrong with this music play script?

Asked by 10 years ago

I had my friend check out my games and he said it is playing two songs at the same time. Is there a problem with this script:

--Made by Stickmasterluke
gw=game.Workspace

function message(text,time)
    local oldmsg=gw:FindFirstChild("Hint")
    if oldmsg then
        oldmsg.Parent=nil
    end
    local spacenumber=time*25
    local msg=Instance.new("Hint")
    msg.Parent=gw
    --[[for i=1, spacenumber do
        wait(1/25)
        local maketext=""
        for i2=1, i do
            maketext=maketext.." "
        end
        maketext=maketext..text
        for i2=1, spacenumber-i do
            maketext=maketext.." "
        end
        msg.Text=maketext
    end]]
    msg.Text=text
    wait(4)
    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

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

Well, I could see you're changing songs every 2 minutes. The Pause method has a problem, which I don't know how to reslove, but since you're changing songs, use the Stop method.

Replace ":Pause()" with ":Stop()"

0
Okay. Thanks :D User#5689 -1 — 10y
0
Glad I could help. Shawnyg 4330 — 10y
Ad

Answer this question