Put Scripts on terrain trees?

Hello, is there any way to add scripts to trees placed on terrain? It seems that it doesn’t work if the tree prefab just has it.
Any help?