Traps work, but at least for squirrels they need released within 18-24 hours or they die. So you need to check them a couple times a day and have a place to release them.
Depending on your state, you might not be able to release them just anywhere, some states you can only trap and release them on your property or kill them on your property.
I had a place to release the squirrels I caught, and again I don't know about raccoons, but I ended up transporting the squirrels 50 miles away. I am pretty sure the ones I released 5-10 miles away came back within a couple of days.