I've made a video of this issue cause it's pretty hard to just explain:
The two capsule collision shapes are two player characters. When you exit the screen you're supposed to loop around, which works fine, but if another player is standing on you when you "loop" they'll be instantly moved to another place on the stage for some reason. It's NOT the script doing this. I think it's related to how kinematic bodies work in Godot. The players move with "move and slide with snap" btw. I've tried turning of the snap and it doesn't change anything.
Well any ideas for avoiding this? Is it a bug in Godot?
Addition: The loop is done by "position.y -= maparea.end.y". I've tried using setdeffered() to change the position, but that also didn't fix the issue.