I'm trying to make something akin to a music player, but when I try to call a coroutine I get this error any idea what could be causing it?
local position = game.Players.LocalPlayer.Character:WaitForChild("Position")
local town1 = game.Soundscape.MusicTown
local wild1 = game.Soundscape.MusicWild1 local v1 = 1
local wild2 = game.Soundscape.MusicWild2
local currentPlaying
local timer =0
function changeSong()
if (timer>= (currentPlaying.TimeLength-1)) and position.Value then
timer = 0
for j=currentPlaying.Volume,0,(-(currentPlaying.Volume/50)) do
currentPlaying.Volume = j
wait()
currentPlaying:Stop()
if currentPlaying == wild1 then
currentPlaying = wild2
else
currentPlaying = wild2
end
currentPlaying:Play()
for j=0,v1,((v1/50)) do
currentPlaying.Volume = j
wait()
end
end
end
end
function loop()
while (wait(1) and position.Value)do
timer = timer+1
local cChangeSong = coroutine.wrap(changeSong())
cChangeSong()
end
end
position.Changed:connect(function()
wait(2)
for i,v in pairs(game.Soundscape:GetChildren()) do
for j=v.Volume,0,(-(v.Volume/50)) do
v.Volume = j
wait()
end
v:Stop()
end
wait(.5)
if position.Value then
wild1:Play()
currentPlaying = wild1
for j=0,v1,((v1/50)) do
wild1.Volume = j
wait()
end
local wLoop = coroutine.wrap(loop())
wLoop()
else
town1:Play()
for j=0,v1,((v1/50)) do
town1.Volume = j
wait()
end
end
end)

3 comments
The error jumps in line 32
you are running the funcion e.g changeSong(). instead of passing the function changeSong
Many thanks!