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

Automatic music player help?

Asked by
NotSoNorm 777 Moderation Voter
9 years ago

Ok so I recently I tried adding a Auto Player to my game, and it worked (for the most part) but now when I tried to add it so the songs fade out at the end and in on the beginning, Nothing works anymore and there are no error outputs. ????

local x = game.Workspace.DJBoardPRO
local o = script.Parent.Parent.Parent

script.Parent.MouseButton1Click:connect(function()
    local Songs = {--200 song ID's--}
    if script.Parent.Text == "Auto Players current status: Off" then
        script.Parent.Text = "Auto Players current status: On"
        while script.Parent.Text == "Auto Players current status: On" do
            o.Header.Text = "AutoPlayer is on"
            x.Sound:Stop()
            x.Sound.Volume = 0
            x.Sound.SoundId = ""
            wait()
            x.Sound.SoundId = "http://www.roblox.com/asset/?id=" .. Songs[math.random(1, #Songs)]
            x.Sound:Play()

                function In() --Where I need help--
                    for i = 0, 1, 0.01 do
                    wait(1)
                    x.Sound.Volume = i

            wait(100)

                function Out() --Where I need help (x2)--
                    for i = 1, 0, -0.01 do
                    wait(1)
                    x.Sound.Volume = i

            x.Sound:Stop()
            x.Sound.SoundId = ""
                        end
                    end
                end
            end
        end
    else
        if script.Parent.Text == "Auto Players current status: On" then
            script.Parent.Text = "Auto Players current status: Off"
            o.Header.Text = "DJ-Board (Revised) V.15.2"
            x.Sound:Stop()
            x.Sound.SoundId = ""
            script.Disabled = true
            wait()
            script.Disabled = false
        end
    end
end)
0
From my past experience, I don't think you can have 3 arguments in a for loop. Ill post an answer. Orlando777 315 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

So I think the problem is your for loops (Please correct me if I'm wrong)

for i = 1, 10  do
          wait(1)
            x.Sound.Volume = x.Sound.Volume -.1
end

This is how this script communicates. We'll repeat this 10 times, wait one second then take .1 away from the volume (Which I assume would be 1). first second : x.Sound.Volume = .9 next second : x.Sound.Volume = .8 next second : x.Sound.Volume = .7 ECT. for 10 times. So by the end of the end of the for loop, it'll be 0

0
Sweet, quick question, If I was to put commands after this, Would it run the commands while the for loop is also running NotSoNorm 777 — 9y
0
I inserted the bit into my script and now where the end of the first secotion of the script it's erroring and I can't fix it no matter how many I add or subtract (Not the end of your bit) NotSoNorm 777 — 9y
0
Correction* It says the 'else' is wrong, Is that cause it is in a for loop? NotSoNorm 777 — 9y
0
Which line? I'm lost because I can't see what you can. Can you post the whole error message? And to answer your question, no, it will wait till the for loop is finished. You might want to look into http://wiki.roblox.com/index.php?title=Beginners_Guide_to_Coroutines Im still new to coroutines. Orlando777 315 — 9y
0
Nvm, I retryed it with a older version of the script and it worked, It must have been something else that made the entire script f up NotSoNorm 777 — 9y
Ad

Answer this question