Declare %lol as a local var so no need to unset them, so include \"%lol\" in the \"var ....\" line
Change this line
set %lol %lol $+ , $+ $comchan($nick,%x)
to
%lol = %lol $comchan($nick,%x)
so there is no need to use $replace as the channels are already being added in the variable separated by a space.
Use \"!\" in your ON Join event which means \"except you\"
on !*:JOIN:#: {
:)