YAYYYYYYY it's working now!!! I didn't change anything, just tried it again a few hours later and it worked. The code works then! I don't understand why the code didnt work earlier though... There must be a major lag between the changes you make in the program and when it actually takes effect when you run the layout.
Thanks to those who helped, sorry i suck at this D: