Most likely you think the code does something when in fact you missed a step or so. What exactly do you want the code
to do?

Right now, it does the following:
If anyone but you (why would you allow anyone to do that anyway - remember you cannot trigger your own on TEXT events!)
types !request yournick #channelname, the code first checks if yournick matches your current nick. If so, it will join
#channelname (personally I'd add a check to see if $3 is a valid channel name). Then it will check the amount of users in the
channel the text was typed in (NOT the channel you just joined), and if the number is smaller than 5, it will prompt an error
(not 100% sure this will actually work, since there is a $calc identifier used that doesn't actually calculate anything, so why
is it even there). It will then also part the channel the command was typed in.
If the amount of users in the channel the command was typed in is more than 4, you will stay in the channel the command was
typed in.

Now I imagine the whole checking and so is supposed to take place in the channel you just joined. That means most your code needs to be changed, as it fails there.

Based on this assumption, you would need to change your code as follows (change the parts in blue as you see fit)

Code:
[color:green]; wait till anyone but you types !request yournick #channelname[/color]
on *:TEXT:!request*:[color:blue]#channelname[/color]: {
  [color:green]; make sure they typed yournick and a valid channelname[/color]
  [color:green]; if so - join the channel and save the requester's name[/color]
  if ($2 == $me) && ($left($3,1) == $chr(35)) { join $3 | set $+(%,req,$3) $nick }
}
[color:blue] [/color]
[color:green]; after joining, wait for the /names list to complete, then check users[/color]
raw 366:*: {
  [color:green]; check usercount[/color]
  if ($nick($2,0) < 5) {
    [color:green]; if there's not enough users, inform the requester[/color]
    .msg $eval($+(%,req,$2),2) [color:blue]Request failed. You do not have the required amount of users in channel.[/color]
    [color:green]; and leave[/color]
    .part $2
  }
  [color:green]; otherwise, stay[/color]
  else .msg $eval($+(%,req,$2),2) [color:blue]Your channel meets the requirements and I will stay. Remember give me op or else my commands wont work.[/color]
  [color:green]; clean up your mess when you're done ![/color]
  unset $+(%,req,$2)
}


Now this code could potentially get your bot into a lot of channels, which could cause serious problems....



DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius