Let d and n be positive integers such that d divides n. An endofunction is a function whose domain is equal to its codomain. Let \([n]=\{1,2,\ldots ,n\}\) and T be an endofunction on [n]. A subset W of [n] of cardinality n/d is d-splitting if \(W \cup TW \cup \cdots \cup T^{d-1}W =[n]\) . Let \(\sigma (d;T)\) denote the number of d-splitting subsets for an endofunction T. If \(\sigma (2;T)>0\) , then we show that \(\sigma (2;T)=g_T(-1)\) , where \(g_T(t)\) is the generating function for the number of T-invariant subsets of [n]. More generally, let \(g_T(t_1,\ldots ,t_d)\) be the generating function for the number of d-flags of T-invariant subsets. We prove that if T is an endofunction whose graph is either a cycle, a tree, or a certain composition of cycles and trees such that \(\sigma (d;T)>0\) , then \(\sigma (d;T)=g_T(\zeta ,\zeta ^2,\ldots ,\zeta ^d)\) , where \(\zeta \) is a primitive \(d^{th}\) root of unity.