It's probably pulling away from the cake when you try piping and that happens when your icing is too thick. Thin it out a bit by mixing in milk or water. That will give it enough moisture to adhere to the cake.