Problem: Including Cl_init in shared or the other way around

So, basically what i’m trying to do is to make a Derma button, that if pushed an entity spawn somewhere on the map.

the problem is that derma is only client side, and ents library shared, and when i push the button i get “Tried TO USE A NULL ENTITY.”, as if i’m trying to run it client side.

here’s the code

client_init.lua:

include(“shared.lua”)

function spawnFrame()

local MyFrame = vgui.Create("DFrame")
    MyFrame:SetPos(ScrW()/2, ScrH()/2)
	MyFrame:SetSize(500, 400)
	MyFrame:SetTitle("Testing derma")
	MyFrame:SetVisible(true)
	MyFrame:SetDraggable(true)
	MyFrame:ShowCloseButton(true)
	MyFrame:MakePopup()
        
		MyButton = vgui.Create("DButton")
		MyButton:SetParent(MyFrame)
		MyButton:SetPos(0,0)
		MyButton:SetSize(250,200)
		MyButton:SetText("spawn")
		MyButton.DoClick = function() 
		    
			spawnEntity()
			
			end

end
concommand.Add(“spawnFrame”, spawnFrame)

shared.lua

–include(“cl_init.lua”)

function spawnEntity(Model_File)

local MyEnt = ents.Create("npc_alyx")
    MyEnt:SetPos(Vector(0,0,100))
	MyEnt:Spawn()
	MyEnt:Activate()

end

First off, remove the line “include(“cl_init.lua”)” (you commented it, but remove it as you will never have to include cl_init.lua).

Secondly: taken from **[Ents.Create

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Ents.Create)**

I am 99% sure that is the problem. Check the console to be sure.

Create the entity server-sided instead.

I’m sorry if i’m being a pain, but how do i create the entity server side?

Make a concommand server-side and make the button call it when clicked.

client_init.lua:

Do you not mean cl_init.lua?

Ok, thanks.

[editline]05:54AM[/editline]

yes, i misspelled it!