You can substitute butter with margarine or shortening, but it may slightly alter the flavor and texture of the cookies. Butter typically provides the best flavor for these cookies.