i have a script where in the middle of the script there is a function that starts like this:
function play() print("playing...")
it never says "playing..."
and i have put a play() at the bottom
full code:
local loop_phase = 1 local playing = false local id = script.Id while true do wait() if playing then if loop_phase == 1 then print("now playing: "..id.Value..".start") script.Library[id.Value].start:Play() wait(script.Library[id.Value].start.TimeLength) loop_phase = 1 elseif loop_phase == 2 then script.Library[id.Value].loop:Play() wait(script.Library[id.Value].loop.TimeLength) end end end function play() print("playing...") for i=0,50,1 do wait(0.01) if loop_phase == 1 then script.Library[id.Value].start.Volume = script.Library[id.Value].start.Volume - 0.2 elseif loop_phase == 2 then script.Library[id.Value].loop.Volume = script.Library[id.Value].loop.Volume - 0.2 end end playing = false if loop_phase == 1 then script.Library[id.Value].start:Stop() elseif loop_phase == 2 then script.Library[id.Value].loop:Stop() end script.Library[id.Value].loop.Volume = 10 script.Library[id.Value].start.Volume = 10 loop_phase = 1 playing = true end play()
the local id = script.Id is a string value set to "adventure"
the script will locate: script.Library[id.Value]["start"] at some point which basicly means script.Library.start
and start is a sound in a folder called adventure in the script
no errors, or the "playing..." i seriously need help
Remember that a script is linear and performs tasks sequentially. In your problem, the problem arises because the script will start the infinite while loop and never end. Thus, the script can't progress to the code after it. If you want to fix this, the simplest and easiest way is to simply move the infinite loop after everything else. This would look like this:
local loop_phase = 1 local playing = false local id = script.Id function play() print("playing...") for i=0,50,1 do wait(0.01) if loop_phase == 1 then script.Library[id.Value].start.Volume = script.Library[id.Value].start.Volume - 0.2 elseif loop_phase == 2 then script.Library[id.Value].loop.Volume = script.Library[id.Value].loop.Volume - 0.2 end end playing = false if loop_phase == 1 then script.Library[id.Value].start:Stop() elseif loop_phase == 2 then script.Library[id.Value].loop:Stop() end script.Library[id.Value].loop.Volume = 10 script.Library[id.Value].start.Volume = 10 loop_phase = 1 playing = true end play() while true do wait() if playing then if loop_phase == 1 then print("now playing: "..id.Value..".start") script.Library[id.Value].start:Play() wait(script.Library[id.Value].start.TimeLength) loop_phase = 1 elseif loop_phase == 2 then script.Library[id.Value].loop:Play() wait(script.Library[id.Value].loop.TimeLength) end end end