Make a hook to open a VGUI?

I am comfused open making a hook to open this vgui this is what I have so far



concommand.Add("!compliment", DermaPanel)
hook.Add( "PlayerSay", "!compliment", function (ply, text, public)
	text = string.lower( text )
	if ( text == "!compliment") then

	
	end
end)

local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 250, 300 )
DermaPanel:SetTitle( "Compliment A Staff Member" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:SetMouseInputEnabled(true)
DermaPanel:SetKeyboardInputEnabled(true)
DermaPanel:MakePopup()



concommand.Add("compliment", DermaPanel)
hook.Add( "PlayerSay", "!compliment", function (ply, text, public)
	text = string.lower( text )
	if ( text == "!compliment") then
                local DermaPanel = vgui.Create( "DFrame" )
		DermaPanel:SetPos( 50,50 )
		DermaPanel:SetSize( 250, 300 )
		DermaPanel:SetTitle( "Compliment A Staff Member" )
		DermaPanel:SetVisible( true )
		DermaPanel:SetDraggable( true )
		DermaPanel:ShowCloseButton( true )
		DermaPanel:SetMouseInputEnabled(true)
		DermaPanel:SetKeyboardInputEnabled(true)
		DermaPanel:MakePopup()
	end
end)


Untested, because I can’t right now.

You can’t create vgui panels in a PlayerSay hook because a PlayerSay hook is serverside and vgui is clientside. I honestly don’t understand why people still have this problem- I’ve seen at least 5 threads asking the exact same thing, so here’s the solution again:



hook.Add( "OnPlayerChat", "!compliment", function(ply, text, team, dead)
	text = string.lower( text )
	if ( text == "!compliment") and ply == LocalPlayer() then
		local DermaPanel = vgui.Create( "DFrame" )
		DermaPanel:SetPos( 50,50 )
		DermaPanel:SetSize( 250, 300 )
		DermaPanel:SetTitle( "Compliment A Staff Member" )
		DermaPanel:SetVisible( true )
		DermaPanel:SetDraggable( true )
		DermaPanel:ShowCloseButton( true )
		DermaPanel:SetMouseInputEnabled(true)
		DermaPanel:SetKeyboardInputEnabled(true)
		DermaPanel:MakePopup()
	end
end)