Shininess is derived from PID, TID, and SID. If you change one of the 3, it may no longer be shiny depending on how the calculation xor changes.
As theSLAYER already told you, you can change things so that the TID and SID keep it shiny, but the TID and SID have to have the same xor as the previous shiny TID / SID.
I suggest that you educate yourself on what determines shininess so that you can make the edits you want.
https://bulbapedia.bulbagarden.net/wiki/Personality_value#Shininess