Gamemode prop shop?

I’ve made a shop gui with derma just I dont know how to spawn props with a command, players arent able to put the command in console themselves they have to use the shop menu

I have this code so far for my buy button


local item = vgui.Create( 'DButton' )
local cash = ply:GetPData( "money", 0 )

item:SetParent( shoppanel )
item:SetSize( 300, 280 )
item:SetPos( 730, 45 )
item:DoClick()
ply:SetMoney( cash - 100 ) 
--[[Code to spawn prop either where they're looking at or infront of them]]--
end

[lua]
local prop = ents.Create( “prop_physics” )
prop:SetModel( “models/whatever.mdl” )
prop:SetPos( ply:GetPos()
prop:Spawn()
[/lua]

You can’t spawn props(in most cases) or set money(unless your gamemode is made in a odd way) clientside.

What I would do would be something like this:
(bad style because I’m writing here in the browser)
[lua]
– Serverside
util.AddNetworkString( “BuyProp” );

net.Receive( “BuyProp”, function( len )
local _p = Entity( net.ReadFloat() ); – player who bought it
local _prop = __props[ net.ReadString ];

– make sure it exists, player can afford it, remove his money etc

local _e = ents.Create( "prop_physics" );
_e:SetModel( _prop[ "mdl" ] );
_e:SetPos( _p:GetPos() + _p:GetForward() * 30 );
_e:Spawn();

end );

– Shared
__props = {};
__props[ “chair” ] = { [ “mdl” ] = “models/chair.mdl”, [ “price” ] = 10 };

– client
local _buttons = {};
for i, v in pairs( __props ) do
_buttons[ i ] = vgui.Create( “DButton”, frame );
_buttons[ i ]:SetLabel( “Buy” … i );
_buttons[ i ].DoClick = function()
net.Start( “BuyProp” );
net.WriteFloat( LocalPlayer():EntIndex() );
net.WriteString( i );
net.SendToServer();
end
[/lua]

Don’t send the player like that.
The second argument of net.Receive is the player who sent it
[LUA] net.Receive( “BuyProp”, function( len, playerWhoBoughtIt ) [/LUA]

Thanks so much everyone for the help :smile: