Give a "entity" to a player from a derma button?

Hey, I am wondering how do you give a player an entity from clicking a button from a derma menu, like a hat entitie and when they click it it goes on their head? A thanks in advance!

Well, you would have the button in the menu call a console command on the server that adds the hat. Before doing so, you would of course check if the player has enough money and all that serverside.

So, something like this:


function showMenu()

button.DoClick = function()
RunConsoleCommand( “buyhat”, “hat3” )



concommand.Add( “buyhat”, function( ply, _, args )
local hat = args[1]
if ( hat and hatsThatAreBuyable[hat] and ply:GetMoney() > hatPrices[hat] ) then
addHat( ply )
end )[/lua]
end )

Thanks for the help!