This wont pop up on spawn

This is my cl_jobpicker.lua


function FactionPicker()

local window = vgui.Create( "DFrame" )
window:SetTitle( "Choose A Faction!" ) 
window:SetSize( 300, 300 ) 
window:Center()
window:SetVisible( true ) 
window:ShowCloseButton( true ) 
window:SetDraggable( true ) 
window:MakePopup() 

DermaImageButton = vgui.Create( "DImageButton", window )
DermaImageButton:SetPos( 50, 52 )								
DermaImageButton:SetSize( 200, 50 ) 
DermaImageButton:SetImage( "materials/us_icon.png" )		 
DermaImageButton:GetStretchToFit()							 
DermaImageButton.DoClick = function()
	RunConsoleCommand ( "say", "/USRecruit" ) 
end

DermaImageButton = vgui.Create( "DImageButton", window )
DermaImageButton:SetPos( 50, 113 )								
DermaImageButton:SetSize( 200, 50 )							
DermaImageButton:SetImage( "materials/ru_icon.png" )		 
DermaImageButton:GetStretchToFit()							
DermaImageButton.DoClick = function()
	RunConsoleCommand ( "say", "/rurecruit" ) 
end

DermaImageButton = vgui.Create( "DImageButton", window )
DermaImageButton:SetPos( 50, 173 )								
DermaImageButton:SetSize( 200, 50 )							
DermaImageButton:SetImage( "materials/uk_icon.png" )		 
DermaImageButton:GetStretchToFit()							
DermaImageButton.DoClick = function()
	RunConsoleCommand ( "say", "/ukrecruit" )
end

DermaImageButton = vgui.Create( "DImageButton", window )
DermaImageButton:SetPos( 50, 233 )								
DermaImageButton:SetSize( 200, 50 )							
DermaImageButton:SetImage( "materials/tali_icon.png" )		 
DermaImageButton:GetStretchToFit()							
DermaImageButton.DoClick = function()
	RunConsoleCommand ( "say", "/talibanrecruit" )
end
	end
	
concommand.Add("Open_FactionPicker", FactionPicker)
net.Receive("OpenFactionPicker", FactionPicker)

This is my sv_netmsg.lua


if SERVER then

util.AddNetworkString("OpenFactionPicker")

function OpenFaction(ply)
    net.Start("OpenFactionPicker")
    net.Send(ply)
end
	end
hook.Add("PlayerInitialSpawn", "OpenFaction", OpenFaction)

It wont pop up and theres no script errors.

playerinitialspawn is called much earlier than the client’s 2d rendering hooks are initialized, you’d be best off either hooking it to run once on hudpaint or have a timer in playerinitialspawn

Its weird cause in a SteamCMD server it works and same thing with the singleplayer, just in my server not run by me it dosnt work. Maybe DermaImageButton is being overun by something. I also have no idea how to do what your talking about XD Im still learning GLua

He means the code of you might be running before 2D stuff are initialized so they won’t work, try to hook to some other hook or create a timer to delay the code til those are init-ed
I got this problem too when creating an entity and hook into Initialize, I solved by increase my timer to 30s

Why not just use the PlayerSpawn hook and check if the player is already in a faction or not?

How would you make a timer? and could I use the PlayerSpawn hook?

Why not run it immediately when the client itself initialized? You don’t need to use the net message, just hook onto InitPostEntity clientside.

Trolling? You can do

[lua]

timer.Simple(seconds, function)
[/lua]

They have all suggested the hook name for you
You could use the gmod wiki to search and find out how it work
It’s a gold mine for beginner :3
I’ll save your click this time


hook.Add("hook name", "an unique name for your hook", function to execute)
-- Example
function Emptystuff ()
           return
end
hook.Add("Initialize", "This is an unique name", Emptystuff)
-- This will run when the server done init-ing

So like this?

EDIT: Didnt seem to work… Im not sure whats happening. Theres no script errors.


function FACTIONPICKER()
    return
		   
print( "Spawning the Faction Picker!" )

local window = vgui.Create( "DFrame" )
window:SetTitle( "Choose A Faction!" ) 
window:SetSize( 300, 300 ) 
window:Center()
window:SetVisible( true ) 
window:ShowCloseButton( true ) 
window:SetDraggable( true ) 
window:MakePopup() 

DermaImageButton = vgui.Create( "DImageButton", window )
DermaImageButton:SetPos( 50, 52 )								
DermaImageButton:SetSize( 200, 50 ) 
DermaImageButton:SetImage( "materials/us_icon.png" )		 
DermaImageButton:GetStretchToFit()							 
DermaImageButton.DoClick = function()
	RunConsoleCommand ( "say", "/USRecruit" ) 
end

DermaImageButton = vgui.Create( "DImageButton", window )
DermaImageButton:SetPos( 50, 113 )								
DermaImageButton:SetSize( 200, 50 )							
DermaImageButton:SetImage( "materials/ru_icon.png" )		 
DermaImageButton:GetStretchToFit()							
DermaImageButton.DoClick = function()
	RunConsoleCommand ( "say", "/rurecruit" ) 
end

DermaImageButton = vgui.Create( "DImageButton", window )
DermaImageButton:SetPos( 50, 173 )								
DermaImageButton:SetSize( 200, 50 )							
DermaImageButton:SetImage( "materials/uk_icon.png" )		 
DermaImageButton:GetStretchToFit()							
DermaImageButton.DoClick = function()
	RunConsoleCommand ( "say", "/ukrecruit" )
end

DermaImageButton = vgui.Create( "DImageButton", window )
DermaImageButton:SetPos( 50, 233 )								
DermaImageButton:SetSize( 200, 50 )							
DermaImageButton:SetImage( "materials/tali_icon.png" )		 
DermaImageButton:GetStretchToFit()							
DermaImageButton.DoClick = function()
	RunConsoleCommand ( "say", "/talibanrecruit" )
end
	end
hook.Add("Initialize", "FactionHOOK", FACTIONPICKER)

No don’t hook on Initialize, that is just an example
Hook is simply a function that call another function on some event, such as Initialize above is run when the server start (or done init-ing, not remember :p)
Like those guy said above, try to hook it to PlayerSpawn and stuff, for more info just visit the wiki
Good luck

[editline]24th December 2016[/editline]

Also you might want to disable the close button so people can’t close the faction picker and become factionless

[editline]24th December 2016[/editline]

If it doesn’t work, try the timer


local function FactionTimer
     timer.Create(60, OpenFaction) --I think 60s is enough delay, but if it spawns too late or too soon (mean not spawning) try reducing/increasing it
end
hook.Add("PlayerInitialSpawn", "Your unique name here", FactionTimer) -- Change the function to FactionTimer so it create the timer not create the Gui

Thank you man, you really helped me out AND your a really nice person.

[editline]24th December 2016[/editline]


local function FactionTimer
   timer.Create(60, OpenFaction)
   
local window = vgui.Create( "DFrame" )
window:SetTitle( "Choose A Faction!" ) 
window:SetSize( 300, 300 ) 
window:Center()
window:SetVisible( true ) 
window:ShowCloseButton( true ) 
window:SetDraggable( true ) 
window:MakePopup() 

DermaImageButton = vgui.Create( "DImageButton", window )
DermaImageButton:SetPos( 50, 52 )								
DermaImageButton:SetSize( 200, 50 ) 
DermaImageButton:SetImage( "materials/us_icon.png" )		 
DermaImageButton:GetStretchToFit()							 
DermaImageButton.DoClick = function()
	RunConsoleCommand ( "say", "/USRecruit" ) 
end

DermaImageButton = vgui.Create( "DImageButton", window )
DermaImageButton:SetPos( 50, 113 )								
DermaImageButton:SetSize( 200, 50 )							
DermaImageButton:SetImage( "materials/ru_icon.png" )		 
DermaImageButton:GetStretchToFit()							
DermaImageButton.DoClick = function()
	RunConsoleCommand ( "say", "/rurecruit" ) 
end

DermaImageButton = vgui.Create( "DImageButton", window )
DermaImageButton:SetPos( 50, 173 )								
DermaImageButton:SetSize( 200, 50 )							
DermaImageButton:SetImage( "materials/uk_icon.png" )		 
DermaImageButton:GetStretchToFit()							
DermaImageButton.DoClick = function()
	RunConsoleCommand ( "say", "/ukrecruit" )
end

DermaImageButton = vgui.Create( "DImageButton", window )
DermaImageButton:SetPos( 50, 233 )								
DermaImageButton:SetSize( 200, 50 )							
DermaImageButton:SetImage( "materials/tali_icon.png" )		 
DermaImageButton:GetStretchToFit()							
DermaImageButton.DoClick = function()
	RunConsoleCommand ( "say", "/talibanrecruit" )
end
	end
hook.Add("PlayerInitialSpawn", "FactionHOOKName", FactionTimer)

This dosnt work. Or are you wanting me to add it to the netmsging?

You’re over-complicating this so much

Trial and error dude, just try hook it on many kind of hook and test, pointing at the post above this post
Also timer and hook should be server side, and timer should be under the OpenFaction function so OpenFaction can be defined before the timer go
And if the PlayerSpawn hook work then you don’t have to create the timer, it’s useless then