The problem is related to carsSpriteInstances instances being destroyed when you switch layouts. You must select the various instances at each level start and not just at project startup.
For example you can do this:
runOnStartup(async runtime => {
runtime.objects.CarSprite.setInstanceClass(CarSprite);
runtime.objects.CheckpointSprite.setInstanceClass(CheckpointSprite);
runtime.addEventListener("beforelayoutstart", () => BeforeLayoutStart(runtime));
runtime.addEventListener("tick", () => Tick(runtime));
});
async function BeforeLayoutStart(runtime) {
checkPointsInstances = runtime.objects.CheckpointSprite.getAllInstances();
carsSpriteInstances = runtime.objects.CarSprite.getAllInstances();
startPointInstance = runtime.objects.StartSprite.getAllInstances()[0];
for(let i = 0; i < checkPointsInstances.length; i++){
checkPointsInstances[i].setIndex(i+1)
}
for(let i = 0; i< carsSpriteInstances.length;i++){
carsSpriteInstances[i].init(checkPointsInstances)
}
}