ID:144078
 
Code:
mob
White_Team
icon = 'teammates.dmi'
icon_state = "white"
Red_Team
icon = 'teammates.dmi'
icon_state = "red"
Blue_Team
icon = 'teammates.dmi'
icon_state = "blue"
Login()
var/red = /mob/Red_Team
var/blue = /mob/Blue_Team
..()
src << "Welcome to TrapWar! Pick your team."
world << "[src.key] is picking \his character!"
switch(alert("What is your team?","Team Selection","Red","Blue","Cancel"))
if("Red")
src.client.mob = red
src.team = "Red"
src.loc = locate(3,24,1)
if("Blue")
src.client.mob = blue
src.team = "Blue"
src.loc = locate(39,24,1)
if("Cancel")
world << "[src.key] decided not to play."
del(src)
src.name = input("What is your name?","Name") as text
usr << "Welcome to the [usr.team] base! Destroy or capture all of the other team to win!"
world << "[src.team] Teammate [src.name] has logged on!"

Logout()
..()
world << "[usr.team] Teammate [src.name] has logged out."
var
team = null


Problem description:
The code compiles just fine, but whenever I run it, it gives me this error:
runtime error: bad client
proc name: Login (/mob/Login)
usr: Guest (/mob/White_Team)
src: Guest (/mob/White_Team)
call stack:
Guest (/mob/White_Team): Login()

I've tried changing the code many times, always doing the same basic thing, but it never works.
What's wrong?!


There's no need to use src.client.mob here because it's going to refer right back to src.
In response to Popisfizzy
I'm trying to change the usr's mob from /mob/White_Team to /mob/Red_Team or /mob/Blue_Team.If I change it to src.mob or usr.mob it gives me a compile-time error.
In response to Armiris
Ah, I see, I didn't look over your code too well. Try and replace var/red = /mob/Red_Team with var/mob/Red_Team/red = new, and the same for var/blue. I'm not absolutely sure that'll work, but I know your current method won't.
In response to Popisfizzy
That just made it worse.
When I ran it, it gaveme this:
Welcome to TrapWar! Pick your team.
Guest is picking character!
runtime error: bad client
proc name: Login (/mob/Login)
usr: Blue Team (/mob/Blue_Team)
src: Blue Team (/mob/Blue_Team)
call stack:
Blue Team (/mob/Blue_Team): Login()

and then it just relogged.
So, what is going on?
In response to Armiris
First post your updated code. To be honest, we don't even know if you followed Pop's instructions right (which should work).