Can't get SetTeam working?

Hey, I got a problem there nothing at all happens when I set the players team. No errors pop out neither…

cl_init.lua



function set_team()
 
local frame = vgui.Create( "DFrame" )
frame:Center()
frame:SetSize( 200, 210 ) --Set the size
frame:SetTitle( "Select Job" ) --Set title
frame:SetVisible( true )
frame:SetDraggable( false )
frame:ShowCloseButton( true )
frame:MakePopup()
 
Label1 = vgui.Create("DLabel", frame)
Label1:SetPos(25,30)
Label1:SetText("Welcome to RailRP!")
Label1:SizeToContents()
Label1:SetTextColor( Color(255, 165, 0, 255) )

Label2 = vgui.Create("DLabel", frame)
Label2:SetPos(25,50)
Label2:SetText("By: Blt950")
Label2:SizeToContents()
Label2:SetTextColor( Color(0, 165, 255, 255) )
 
Team1 = vgui.Create( "DButton", frame )
Team1:SetPos( 25 , 90 )
Team1:SetSize( 150, 20 )
Team1:SetText( "Citizen" )
Team1.DoClick = function()
    RunConsoleCommand( "Team1" )
	frame:SetVisible(false)
end
 
Team2 = vgui.Create( "DButton", frame )
Team2:SetPos( 25 , 120 )
Team2:SetSize( 150, 20 )
Team2:SetText( "Train Driver" )
Team2.DoClick = function() 
    RunConsoleCommand( "Team2" )
	frame:SetVisible(false)
end

Team3 = vgui.Create( "DButton", frame )
Team3:SetPos( 25 , 140 )
Team3:SetSize( 150, 20 )
Team3:SetText( "Ticket Controller" )
Team3.DoClick = function() 
    RunConsoleCommand( "Team3" )
	frame:SetVisible(false)
end

Team4 = vgui.Create( "DButton", frame )
Team4:SetPos( 25 , 160 )
Team4:SetSize( 150, 20 )
Team4:SetText( "Builder/Engineer" )
Team4.DoClick = function()
    RunConsoleCommand( "Team4" )
	frame:SetVisible(false)
end
 
end
concommand.Add( "team_menu", set_team )


init.lua




function GM:PlayerLoadout( ply )
	ply:StripWeapons()
	
	if ply:Team() == 1 or ply:Team() == 2 then
 
        ply:Give( "weapon_physcannon" )
		ply:Give( "weapon_crowbar" )
	elseif ply:Team() == 3 then
		ply:Give( "weapon_physcannon" )
		ply:Give( "weapon_crowbar" )
		ply:Give( "weapon_pistol" )
		ply:GiveAmmo( 200, "pistol" )
	elseif ply:Team() == 4 then
		ply:Give( "weapon_physcannon" )
		ply:Give( "weapon_physgun" )
		ply:Give( "weapon_crowbar" )
	end
 
end

// Set Team
function SetTeam1( ply )
    ply:SetTeam( 1 )
end
 
function SetTeam2( ply )
    ply:SetTeam( 2 )
end

function SetTeam3( ply )
    ply:SetTeam( 3 )
end

function SetTeam4( ply )
    ply:SetTeam( 4 )
end
 
concommand.Add( "Team1", SetTeam1 )
concommand.Add( "Team2", SetTeam2 )
concommand.Add( "Team3", SetTeam3 )
concommand.Add( "Team4", SetTeam4 )


As I told, I can even write the command in console. And nothing, absolutely nothing happens.

That’s because nothing is supposed to happen when you change a player’s team. All it does is change a variable on the player. If you want to change their loadouts and all that, then you’ll probably have to respawn them.

Not exactly, you could strip their weapons and give them their new ones.

ply:Spawn()

worked since 2006

Fixed it now by loading their loadouts after team change :slight_smile: Thanks