The :isOnGround() calculation is the problem, and that resolution won't even work. You have to account for walking into an object from all sides, and you have to resolve the collision correctly, depending on which side they've walked on. If you don't do it correctly, there are a number of things that can go wrong, such as, the player 'teleporting' to the top of the block when walking into it, getting stuck inside the block, being slightly inside of a block instead of standing on top of it, and so on. Top-down collision is hella easier, trust me.
Collision in general is a bitch, though. Which is why I recommend you just let a library do it for you.