You didn't include any script involving creating a dynamic trigger for events. Easier words: None of the scripts that have been pasted here are in the pastebin you sent.
Sidenote: You have 2 join events and one too many closing brackets.
I'll Make a different one. I took the Adding and removing commands out of the script. here is it with it. Is there anyway you could check why it does not work?. http://pastebin.com/bhVzxeQF
This will only work in the channel #test since you specified it to be only used in that channel. Remove test so you only have # and it will work on all channels.
You still have an extra closing bracket at the end however.