Here is what i have. This is WDL script.
Code:
entity ghostobject
{
	flags = TRANSLUCENT;
	alpha = 30;
}
var isplaceobject = 0;
function spawn()
{
	while(isplaceobject == NULL)
	{
	temp.x = mouse_pos.x;
	temp.y = mouse_pos.y;
	temp.z = 0;
	
	vec_set(target,temp);
	target.z = 10000;
	
	vec_for_screen(temp,view_build);
	vec_for_screen(target,view_build);
	
	if(c_trace(temp,target,IGNORE_ME | IGNORE_PASSABLE) > 0)
	{
		if(mouse_left)
		{
			ent_create("crate.mdl",target,null);
			if(ghostobject == NULL)
			{
				ent_remove(ghostobject);
				isplaceobject = 0;
			}
			
		}
		if(ghostobject == NULL)
		{
			ghostobject = ent_create("crate.mdl",target,NULL);
		}
		else
		{
			vec_set(ghostobject.x,target);
		}
		wait(1);
	}	

	}
	

}



Now the thing is when i click, it creates a huge line of boxes from the target to the camera. Also no ghost box appears, and when you click the engine just crashes from overwhelming boxes.