The suttas (SN 12.37) say [the results of] old kamma are to be felt [as feelings] & not identified with (not acted upon). This will dissolve the results of old kamma. This is why the suttas (AN 6.63) say the Noble Eightfold Path destroys/ends kamma.
As for Moggallāna, according to mythology, he was attacked because he made the Jain religion look bad when he reported Jain followers had poor rebirth. This is just a worldly matter and unrelated to any kamma of Moggallāna because, as an Arahant, Moggallāna would not have identified with any past actions & present painful feelings & therefore would not have suffered when he was attacked.
Many people hated the Buddha & wanted to kill him. That people hated the Buddha is not related to the Buddha's kamma. The Buddha has no "kamma" in the ordinary sense of the word.
MN 117 explains the ordinary meaning of "kamma" is connected to "asava" ("defilements" ) and "acquisitions" ("upadhi"; "attachment"). Arahants are free from "acquisition" thus are free from "kamma".