Need help with a buy menu

I’m creating a gamemode and i need a buy menu where a player can buy weapons from. I have to have the menu client side because the function to open the menu must be client sided. I would like to either know how i can put

hook.Add( "Think", "BM_Clients_Key", function()
    if input.IsKeyDown( KEY_B ) then BuyMenu()

client side seperately while holding the menu server side, so i can run ply:Give in the file, or how to run ply:Give on a seperate server-side file from the client-side buy menu.

local Shotgun = vgui.Create( "DButton", BackGround )
        Shotgun:SetSize( 150, 150 )
        Shotgun:SetText( "Shotgun" )
        Shotgun:SetPos( 10, 10 )
        function Shotgun:DoClick()
            ply:Give( "weapon_shotgun" )

While i’m here, i might as well ask how i can get the input:IsKeyDown to run once per press so it doesnt open 60 menus per second

:Give() is a serverside function.
You need to do some networking.

I know that it is a serverside function, i just want to know how i can get the player to press “B” in a client-side file and run the buy menu server-side which would allow :Give() to work and thus giving the player a weapon.

You can’t run vgui serverside, you’re going to have to network it when they press the button. If you mean you want the player to press the key b, then they’re given a weapon you’re also going to have to do some networking.

He probably wants the menu to open by pressing “B”

Use the net library to send a request to the server to run a special function.

You should also use the keypress hook instead of Think.

Correct, and inside the menu is a button the player presses to give them the weapon.

I would you the keypress hook but that requires a pre-set key based on a function (W would be " IN_FORWARD)

-Snip, misread your reply, again-