2 commands if you use 1 it wont work so use both commands psst type the first command in a command block put another command block on top type the second one
then go back to the first put it on always active then your ready to go Psst Hint to get a command block type /give @p command_block