Derma frame won't close?

Hi. I’m making a scoreboard and i’ve tried making a hide scoreboard function that does not seem to be working. I’ve checked on the wiki and i can’t see any mistakes that i have made. Please could somebody advise on what i have done incorrectly? Code is below




function ShowSleepyScoreboard()

	gui.EnableScreenClicker(true)
	local SleepyScoreboard = vgui.Create("DFrame")
		SleepyScoreboard:SetPos( ScrW() * 0.25, ScrH() * 0.045 )
		SleepyScoreboard:SetSize( ScrW() * 0.5, ScrH() * 0.9)
		SleepyScoreboard:SetDraggable( false )
		SleepyScoreboard:ShowCloseButton( false )

end

function HideSleepyScoreboard()
	if IsValid( SleepyScoreboard ) then
		gui.EnableScreenClicker(false)
		SleepyScoreboard:Remove()
	end
end

function OverrideDefaultScoreboard()
	CreateClientConVar("FAdmin_IsScoreboard", 0, false, false) 
	hook.Remove("ScoreboardHide", "FAdmin_scoreboard")
	hook.Remove("ScoreboardShow", "FAdmin_scoreboard")
	GAMEMODE.ScoreboardHide = HideSleepyScoreboard
	GAMEMODE.ScoreboardShow = ShowSleepyScoreboard
end

hook.Add( "InitPostEntity", "Initialize", function(w)
	for i= 1, 5 do
		timer.Simple(i,function() OverrideDefaultScoreboard() end)
	end
end)



Many thanks.

I’m not sure if this would work or not, but rather than setting them by doing this:



GAMEMODE.ScoreboardHide = HideSleepyScoreboard


Try adding your scoreboard as a hook with the same settings as the one you just removed

[editline]7th April 2016[/editline]

Also, why are you running the OverrideDefaultScoreboard function 5 times with different timers?