GMod ents.Create | Entity spaws for a short moment but removes after spawned!



NPCShop_Items["item_normallock"] = { 
	Name = "Normal Lock", 
	Description = "A normal lock, used to secure and lock doors.",
	Model = "models/custom/dlock.mdl",
	Price = 500, 
	BuyFunction =
		function(item)
			local lock = ents.Create( "normal_lock" )
				if ( !IsValid( lock ) ) then return end
				lock:SetModel( "models/custom/dlock.mdl" )
				lock:SetPos( Vector( 2043, 3360, -144 ) )
				lock:Spawn()
		end,
}


This code makes an NPC spawn a lock infront of him.
Whats strange is that the lock model only flickers for a small moment, the lock spawns in quickly, then quickly removes itself from the world. Why does this happen and how can I fix this? Thanks!

ur doing it clientside

do it serverside

How do I do that? I am new to lua so I would appreciate some detailed and specific guidelines.

dont send the file to the client, done.

I am new to lua, your “help” isn’t helping me. How do I make it clientside? Please answer more detailed.

Is ents.Create even available clientside? Wiki says it’s serverside only.

ye it is - u can make clientside entities they just disappear or something if not done properly like the op describes

How do I make it server-side, the script is inside shared.lua



if ( SERVER ) then
-- your code
end


If i put the code on serverside, then the NPC won’t show any items.
What should I do to make the entity spawn server-side?

Not all things work server side. Go on The gmod wiki and read up. You can find everything about clientside and server side on there.

The reason it doesn’t show any items is because all visual interfaces (dermas etc) are client side only, you need to work with both client and server. With how little you seem to know about everything. I assume you followed some kind of tutorial to get the code you have now. Read carefully and see where you went wrong.

I know I’m late af in this reply but that’s just plain lies

] lua_run_cl print(ents.Create)
nil
] lua_run print(ents.Create)
> print(ents.Create)…
function: 0x1c062c90

what the hell matt?

settle down friend - it used to be, I had no idea it was actually removed

You’re probably thinking of ents.CreateClientProp()

no I was thinking of pre gmod 13