I completely remade all of the code and it seems to work now. Sorry if I kind of like wasted your time or smth.