ShowSpare2 issue

I’ve been trying to get F4 to open a VGUI derma. It works in singleplayer but in multiplayer, it never opens.



surface.CreateFont( "akbar", {
 font = "akbar",
 size = 25,
 weight = 500,
 blursize = 0,
 scanlines = 0,
 antialias = true,
 underline = false,
 italic = false,
 strikeout = false,
 symbol = false,
 rotary = false,
 shadow = false,
 additive = false,
 outline = false
} )

function DonatorMenu()

                local BackGround = vgui.Create( "DFrame" )
                 BackGround:SetSize( 650, 320 )
                 BackGround:SetPos( 600, 350 )
                 BackGround:SetTitle( "Donator Benefits" )
                 BackGround:SetVisible( true )
                 BackGround:SetDraggable( false )
                 BackGround:ShowCloseButton( true )
                 BackGround:MakePopup()
                 BackGround.Paint = function()
                        draw.RoundedBox(25, 0, 0, BackGround:GetWide(), BackGround:GetTall(), Color(0,0,0,200))
                        draw.RoundedBox(25, 0, 0, BackGround:GetWide()-4, 21, Color(0,0,0,200))
                        end

local DonatorText = vgui.Create( "DLabel", BackGround )
DonatorText:SetPos( 295, 1 )
DonatorText:SetFont("akbar")
DonatorText:SetTextColor( Color(255, 150, 0))
DonatorText:SetSize( 180, 180 )
DonatorText:SetText( "Benefits" )

local RegDonator = vgui.Create( "DLabel", BackGround )
RegDonator:SetPos( 80, 50)
RegDonator:SetFont("akbar")
RegDonator:SetTextColor( Color(255, 150, 0))
RegDonator:SetText( "Regular Donator" )
RegDonator:SetSize( 180, 180 )

local RegDonator2 = vgui.Create( "DLabel", BackGround )
RegDonator2:SetPos( 120, 70)
RegDonator2:SetFont("akbar")
RegDonator2:SetTextColor( Color(255, 150, 0))
RegDonator2:SetText( "<$10" )
RegDonator2:SetSize( 180, 180 )

local InformationForDon = vgui.Create( "DLabel", BackGround )
InformationForDon:SetPos( 60, 90 )
InformationForDon:SetFont("akbar")
InformationForDon:SetTextColor( Color(255, 150, 0))
InformationForDon:SetText( ".1000 Boltz per Dollar" )
InformationForDon:SetSize( 250, 250 )

local InformationForDon2 = vgui.Create( "DLabel", BackGround )
InformationForDon2:SetPos( 30, 105)
InformationForDon2:SetFont("akbar")
InformationForDon2:SetTextColor( Color(255, 150, 0))
InformationForDon2:SetText( ".Spawning with a random weapon" )
InformationForDon2:SetSize( 300, 300 )

local InformationForDon3 = vgui.Create( "DLabel", BackGround )
InformationForDon3:SetPos( 30, 150)
InformationForDon3:SetFont("akbar")
InformationForDon3:SetTextColor( Color(255, 150, 0))
InformationForDon3:SetText( ".50% discount in the PointShop" )
InformationForDon3:SetSize( 300, 300 )

local MegaDonator = vgui.Create( "DLabel", BackGround )
MegaDonator:SetPos( 430, 50)
MegaDonator:SetFont("akbar")
MegaDonator:SetTextColor( Color(255, 150, 0))
MegaDonator:SetText( "Mega Donator" )
MegaDonator:SetSize( 180, 180 )

local MegaDonator2 = vgui.Create( "DLabel", BackGround )
MegaDonator2:SetPos( 470, 70)
MegaDonator2:SetFont("akbar")
MegaDonator2:SetTextColor( Color(255, 150, 0))
MegaDonator2:SetText( "$10+" )
MegaDonator2:SetSize( 180, 180 )

local InformationForMegDon = vgui.Create( "DLabel", BackGround )
InformationForMegDon:SetPos( 410, 82 )
InformationForMegDon:SetFont("akbar")
InformationForMegDon:SetTextColor( Color(255, 150, 0))
InformationForMegDon:SetText( ".All Donator Privileges " )
InformationForMegDon:SetSize( 250, 250 )

local InformationForMegDon2 = vgui.Create( "DLabel", BackGround )
InformationForMegDon2:SetPos( 400, 150 )
InformationForMegDon2:SetFont("akbar")
InformationForMegDon2:SetTextColor( Color(255, 150, 0))
InformationForMegDon2:SetText( ".Access to Beta Testing " )
InformationForMegDon2:SetSize( 200, 200 )

local InformationForMegDon3 = vgui.Create( "DLabel", BackGround )
InformationForMegDon3:SetPos( 370, 150 )
InformationForMegDon3:SetFont("akbar")
InformationForMegDon3:SetTextColor( Color(255, 150, 0))
InformationForMegDon3:SetText( ".75% discount in the PointShop" )
InformationForMegDon3:SetSize( 300, 300 )

end
concommand.Add( "donatormenu", DonatorMenu )

function DonatorMenuKey( ply )
	ply:ConCommand( "donatormenu" )
end
hook.Add("ShowSpare2", "DonatorMenuKey", DonatorMenuKey)


Where are you saving the file?

Chances are you’re attempting to use a serverside hook on clientside. Most people use a net/user message to make the user open the derma menu. A worked example can be found here.

ShowSpare2 is a server side hook, so you could send a net message or run a console command on the player to open the menu.

Does anyone have an explanation why it worked in singleplayer but not in my server? I will fix it now but any explanation would help others. Thank you!

You are registering the console command on both client and server and that won’t work. Wrap it around in


 if CLIENT then /*my console command*/ end

Be sure to restart server and client.
I am not sure if the files is shared, so you might want to make it shared, if you use my solution.