NULL Entity on ReadEntity()

I’ve got a net message going from server->client that writes an entity, but when it’s received client-side the entity is Null - The entity itself is a nextbot I created:

Server-side:



function Hint:ClientCreate( target )
	net.Start( "GAME_Hint_Create" )
		if isentity( self:GetTrigger() ) then
                        print( "IS ENTITY" )
			print( self:GetTrigger() )
			net.WriteEntity( self:GetTrigger() )
		end
	net.Send( self:GetTargets() )
end


Server-side Output:



> IS ENTITY
> NextBot [65][npc_marshal]


Client-side:



function hint.Create()
        print( "Creating locally" )
	local trigger = net.ReadEntity()
	print(trigger)
end
net.Receive( "GAME_Hint_Create", hint.Create )


Client-side Output:



> Creating locally
> [NULL Entity]


[editline]6th February 2017[/editline]

Solved

As I was doing this on spawn, the entity hadn’t been created client-side yet, so adding a 0.1 second delay fixed this.

http://forum.facepunch.com/showthread.php?t=1254042&p=39925699&viewfull=1#post39925699
http://forum.facepunch.com/showthread.php?t=1254042&p=39925923&viewfull=1#post39925923