I wish a player could not move away more than 3 blocks from an entity or get closer than 3 blocks

It’s a bit complicated to explain but I wish a player could not move away more than 3 blocks from an armor stand or get closer than 3 blocks, that he is blocked in this radius. If someone has a solution I am taker thank you

Continue to help post