Set parent entity of entity?

I have an entity (the parent) called X. Entity X spawns entity B. How do I then set the parent of entity B to entity X?

I have tried:

local ent = ents.Create(self.EntityIn)

to no avail:


[ERROR] addons/test/entities/entities/empty/init.lua:63: attempt to call method 'GetEntity' (a nil value)
  1. unknown - addons/test/entities/entities/empty/init.lua:63

EntityIn is equal to : durgz_weed

Where’d you get “GetEntity()” from? Just use self

Doing that just makes the entity spawn and freeze in mid air.