There can be two main reasons why barfi is not setting. Either you overcooked the mixture due to which it's dry and crumbly (no moisture) and so it is not setting. To fix the dry mixture, transfer it back to a pan, add some milk or cream a tablespoon at a time and cook until it is moist (not wet) and holds shape. Your barfi will also not set if the mixture has too much moisture, to fix this, simply cook till most of the moisture has been absorbed and then set.