I have two triggers both looping while the players stand it. one starts the music while the other trigger stops it
while the player stands in it. The problem is once the player stands in the stop looping sound second trigger the music keeps on playing.

How do i get the music to stop playing in the second trigger the player stands in?



function soundbox1()////////PLAYS SOUND LOOP WHILE PLAYER IS IN THE TRIGGER
{


soundbox1_trig = GetEnt("area_sound1", "targetname");
soundbox1_trig waittill("trigger");


players = GetPlayers();

for (i = 0; i < players.size; i++)


while(1)
{

while(!(players[i] istouching(soundbox1_trig)))


wait 0.5;




iprintlnbold("playing sound");
players[i] PlayLoopSound( "jack" );

wait 8;

}

}



function soundbox1_stop()////////STOPS SOUND LOOP WHILE PLAYER IS IN THE TRIGGER
{


soundbox2_trig = GetEnt("area_sound2", "targetname");
soundbox2_trig waittill("trigger");


players = GetPlayers();

for (i = 0; i < players.size; i++)


while(1)
{

while(!(players[i] istouching(soundbox2_trig)))


wait 0.5;




iprintlnbold("stoping sound");
players[i] StopLoopSound( "jack" );/////////THIS DOSEN'T WORK SOUND STILL PLAYS!


wait 8;

}

}