I have managed to fix it through blueprint.
The solution given everywhere was to set the filter to “Nearest”, but there was no such option in the render target texture editor. However, this option does exist in blueprints.
So the following implementation solved the issue for me: