The @r tag does not work when you if tag an entity. (example: @r[type=pig])
It will however work if without the type tag. (example: @r)
Steps to reproduce:
1) Spawn 3-4 pigs and try the following the command: execute as @r[type=pig] run say hey
You should notice nothing happens.
2) Now get a friend on your Minecraft server and execute the following command: execute as @r run say hey
It works flawlessly if you do not tag any entities.
Thank you for your report!
However, this issue is a Duplicate of MC-121740.
It has been linked to this report. If you have additional information, please add it to that report.
Please search before reporting, as it's likely that one exists already.
Quick Links:
📓 Issue Guidelines – 💬 Community Support – 📧 Customer Support – 📖 Game Wiki