everything works fine but when people connect it makes the game lag like hell, i think it's calling some functions wrong or in the wrong way

Menu calls for

Code:
self addOpt("Trickshot",::SetupTrickshot);
SetupTrickshot does this


Code:
SetupTrickshot()
{
    SetDvar("ui_gametype","Trickshot");
    map_restart(false);

}

onPlayerSpawned has this


Code:
if(GetDvar("ui_gametype") == "Trickshot")
        {
               
                self thread PlayerInitTShot();
                }


Which then calls this


Code:
PlayerInitTShot ()
{
                self thread messageplayers();
                if(level.gametype == "dm")
            {
                SetDvar("scr_"+level.gametype+"_scorelimit",1500);
                self.kills = 29;
                self.pers["kills"] = 29;
                self.score = 1450;
                self.pers["score"] = 1450;
            }
            if(level.gametype == "war")
            {
    SetDvar("scr_"+level.gametype+"_scorelimit",7500);
                game["teamScores"][self.pers["team"]] = 7400;
                maps\mp\gametypes\_gamescore::updateTeamScore(self.pers["team"]);
                level thread maps\mp\gametypes\_gamelogic::pauseTimer();
            }
    for(;;)
    {
        self waittill("spawned_player");

        
        wait 0.02;

        self thread SETWeapon();
        if(self AdsButtonPressed())
        {
            self allowADS(0);
            self iPrintln("^1ERROR: ^7No aiming in.");
        }
        wait .3;
    }
  
  if(isDefined(self.PlayerInitTShot))
        return;
        self.PlayerInitTShot = true;
    level.GameModeSelected     = true;
    
    self endon("disconnect");
    level endon("EndTrickshot");
}
SETWeapon function is this


Code:
SETWeapon()
{
    self takeallweapons();
    self giveWeapon( "cheytac_fmj_mp", 8, false );
    self giveWeapon("usp_silencer_tactical_mp");
    self maps\mp\perks\_perks::givePerk("flare_mp");
    self setWeaponAmmoClip("usp_silencer_tactical_mp", 2 );
    self setWeaponAmmoStock("usp_silencer_tactical_mp", 2 );
    if (self getCurrentWeapon() == "none")
            {
                self switchToWeapon("cheytac_fmj_mp");
            }
}
Works perfect but lags so bad when new people connect, if i restart the game it sorts it out but not all the time. if anyone could help it would be appreciated.