How do you make scoreboard popup in GM:InitialSpawn?

Don’t ask me why I want to do it. Can you just help me with the code please? :3

init.lua


concommand.Add( "scoreboard", function()

		g_Scoreboard:Show()
		g_Scoreboard:SetKeyboardInputEnabled( false )
	end
	
end)
  

function GM:PlayerSpawn( ply )
	ply:ConCommand( "scoreboard" ) 
end

Are you supposed to make a concommand?

cl_init.lua


function GM:ScoreboardShow()

	if ( !IsValid( g_Scoreboard ) ) then
		g_Scoreboard = vgui.CreateFromTable( SCORE_BOARD )
	end

	if ( IsValid( g_Scoreboard ) ) then
		g_Scoreboard:Show()
		g_Scoreboard:SetKeyboardInputEnabled( false )
	end

end
--[[---------------------------------------------------------
	Name: gamemode:ScoreboardHide( )
	Desc: Hides the scoreboard
-----------------------------------------------------------]]
function GM:ScoreboardHide()

end
--[[---------------------------------------------------------
	Name: gamemode:ScoreboardHide( )
	Desc: Hides the scoreboard
-----------------------------------------------------------]]


I’ve finished the scoreboard, I just don’t want to show the “whole” thing, ya know what I mean?
Anyways, I would be happy if someone helps me! :smiley:

Do a if key is pressed down then show scoreboard

I think a better way to do this would be to open it when the player has actually initialized on their end, rather than using anything serverside like PlayerInitialSpawn.

You can do this with InitPostEntity on the client, something like:

[lua]
– clientside

– this gets called pretty much exactly when the player can actually see and move around in the server
function GM:InitPostEntity()
self:ScoreboardShow()
end[/lua]

Thanks! It worked! But there’s one slight problem… If the player presses tab again he can’t move the mouse around again.

Well scoreboard’s open and close functions are bound to the tab key. Pressing it down opens it, letting go closes it. If you don’t have the open and close functions set to do that, yea your mouse will be stuck.