Entity not accepting NWString

So i’ve got this code to set a door’s NWString when the gamemode loads the data from a txt file:
(I know its messy)



function CAKE.SetDoorTitle( entity, title )
    recdoor = tostring( entity )
	--entity:SetNWString("doortitle", title )
	if string.len(recdoor) == 32 then
	    ents.GetByIndex( string.sub( recdoor, 9, 11 )):SetNWString( "doortitle", title ) 
		print( "1" )
		print( ents.GetByIndex( string.sub( recdoor, 9, 11 )) )
		print( title )
	elseif string.len(recdoor) == 33 then
	    print( "2" )
	    ents.GetByIndex( string.sub( recdoor, 9, 12 )):SetNWString( "doortitle", title ) 
	else
	    print( "[DOORS] LENGTH FAILURE" )
	end
	--print( "SentTitle" .. title )
	--9
	--print( string.sub( recdoor, 9, 11 ) )
	--print( "Found Ents" .. table.ToString( foundent ) )
end


Except, all the correct information prints in my debug prints but the entity isn’t getting the NWString set.

Try using net library instead.
Atleast it doesn’t update each second, just when you want it to.

Fixed the problem, was trying to set the NWString too soon.