command working on the in-game command line but does not work when executed in the mcfunction file

JAVA 1.21

So basically I am making a datapack that displays the health, speed and jump height of a horse in chat because i want to use this in my survival world to find the horse with good stats. I was first testing the command which displays the health, i ran the command in the in-game command line and it went through, but when i tried setting off the command in the mcfunction file it was not displaying anything in chat.

I made a similar post about this on reddit but the solutions that they gave did not solve my problem.

Please help, I just want some good horses XD.

Continue to help post