The effects_changed advancement trigger should work after an effect is given to or taken from the player.
When using a player predicate in the advancement trigger to attempt to check if a certain effect is taken from the player, it is rather checked before the effect is taken away from them:
- Create an advancement such as the one shown above to check for a certain effect taken from the player.
- Create a reward function for the advancement:
- Use a Potion of Swiftness or /effect give @s speed to get the Speed effect.
- Use a Milk Bucket or /effect clear to clear the effect.
→ The advancement is not granted and the message is not displayed.
An attached data pack is provided below for easier reproduction.