remove the concommand.Add line and replace it with
hook.Add( “Initialize”, “Teamselect”, set_team)
parameters for hook.Add are hookname, name, functionname
certain hooks are activated on a specific condition, in this case, the Initialize hook is called when a player joins. You can get the full list of hooks and what they do at http://wiki.garrysmod.com/?title=Gamemode_Hooks. Read up on this tutorial: http://wiki.garrysmod.com/?title=LUA:Global_and_Local , you’ll want to declare most variables like the ones in this file as locals, as it will run faster.
Fixed version:
[lua]
include( ‘shared.lua’ )
function set_team()
local Ready = vgui.Create( “DFrame” )
Ready:Center()
Ready:SetSize( 400, 150 )
Ready:SetTitle( “Welcome to |TC| Naval War, Choose your team!” )
Ready:SetVisible( true )
Ready:SetDraggable( true )
Ready:ShowCloseButton( true )
Ready:MakePopup()
local ready1 = vgui.Create( "DButton", Ready )
ready1:SetPos( 20, 25 )
ready1:SetSize( 140, 40 )
ready1:SetText( "Team Red" )
ready1.DoClick = function()
RunConsoleCommand( "sb_team1" )
end
local ready2 = vgui.Create( "DButton", Ready )
ready2:SetPos( 20, 70 )
ready2:SetSize( 140, 40 )
ready2:SetText( "Team Blue" )
ready2.DoClick = function()
RunConsoleCommand( "sb_team2" )
end
end
hook.Add( “Initialize”, “Teamselect”, set_team)
[/lua]
Also one more problem you had: you cannot have two variables with the same name unless they are locals and in different scopes, you had two
ready1 = vgui.Create( “DButton”, Ready ) declared.