I hope this is useful for you, but the less armored people need to use the brain intead of the weaponry. I'm going to answer from my limited knowledgement of warfare.
PD: Sorry for my english.
Primitive defender vs advanced attackers
The best scenario for the "primitive people" (I'm going to call them that way, if you don't mind). Here, you need to use the environment to made defences. There are plenty of defensive tactics to use. They can make an improvised fortification like the romans used to make. The tactics points are reduce the attackers number until the others run away (that's how battles always end, when people run for they lives). Use traps, ambushes, etc.
Advanced defenders vs primitive attackers
If the defenders got "guns", like you said, well... it's gonna be hard. If they build a trench, they are defended enough to considerably reduce the attackers numbers. No single human with a healthy mind would run directly to a trench in a suicide mission for the good of the country (warfare ain't like the movies). The primitive attackers would run for they lives.
Open field battle
You would like the Battle of Farsalia: https://e.wikipedia.org/wiki/Batalla_de_Farsalia
Caesar were outnumbered by Cneo's (Cneo is also known as Pompey) forces (it's not your issue, but could help), so he "hid" some of their troops in a new line. When cavalry hit the troops, found that new soldiers were behind. They ran away, if I don't misremember. Next, Caesar troops flank Cneo forces in a "surprise" attack, making them ran and winning an important battle.