Can you wait and buy it when you arrive? YES
Sweets are hands to have to keep your spirits up, to moisten your mouth when you are thirsty, and to offer to the children who want to talk to you / show you the way etc
A global downside to travel is the increasing likelihood that children will pester you, demanding money or pens - this is an unfortunate side effect of well meaning travelers who have been generous in the past, and it seems that almost every developing country has its black spots where this happens. In cities this can have the added worry of being a distraction whilst your pockets are picked- so be aware of the possibilities.
Considering how wealthy the average backpacker is when you look at the people in Uganda, to stop being generous seems petty minded, but at the same time past gestures have sometimes created monsters. Offering sweets is a reasonable half way position. Young people love them, but they also eat them on the spot. That means that older teens or adults can't take the goodies away from them, something that can often happen with money and items with resale value.
Stock up with long lasting sweets when you are in towns- the rural areas where you are most likely to have contact with groups of the locals are also the places where sweets are rare or non-existent.
If in doubt how to proceed when you want to share or say thank you, offer a bag of sweets to one of the village women, explaining that they are for the children. She will make sure they are handed out, and the crowd will gather round her, not you.