Derma menu spawning an ent

I have a derma menu with a button on it, when the button gets pressed i want an ent i have already made to be created.

Here is the code i have so far,
function testframe()

local DermaPanel = vgui.Create( “DFrame” )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 200, 250 )
DermaPanel:SetTitle( “Gui” )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()

local DermaButton = vgui.Create( “DButton” )
DermaButton:SetParent( DermaPanel ) – Set parent to our “DermaPanel”
DermaButton:SetText( “Spawn Bath” )
DermaButton:SetPos( 25, 50 )
DermaButton:SetSize( 150, 50 )
DermaButton.DoClick = function (tr)

local ent = ents.Create( "prop_physics" )

ent:SetModel( “models/props_c17/FurnitureChair001a.mdl” )
ent:SetPos(tr.HitPos + Vector(0,0,50))
ent:Spawn()

end

end
concommand.Add(“testframe”, testframe)

The error i am getting is,

autorun/client/derma.lua:21: bad argument #1 to ‘?’ (Vector expected, got nil)

Line 21 is “ent:SetPos(tr.HitPos + Vector(0,0,50))”

1.You’re attempting to use ents.Create() serverside
2.You get the Vector error due to the fact that tr is not defined.

3.What you want to do is write a serverside function and add a concommand to it named: gm_spawn

Then do this instead:

[lua]
DermaButton.DoClick = function()
RunConsoleCommand(“gm_spawn”, “models/props_c17/FurnitureChair001a.mdl” )
end
[/lua]

Doesn’t that just spawn a chair tho? I want it to spawn and ent.

Read my post again, I explained it clear enough for you to understand.