You need to define "minCreeps" first. Since it doesn't exist you're trying to add a property to undefined, which doesn't work. if(Game.spawns.Spawn2.memory.minCreeps) { Game.spawns.Spawn2.memory.minCreeps = {}}Game.spawns.Spawn2.memory.minCreeps.lorry = 2