Skip to content
← Back to Community
PLS HELP ME MAKE A HEALTH RPG SYSTEM!!
Profile icon
yBen2201

guys I am learning python and I started creating a simple RPG game to kill monsters, animals, gain XP, rank up and stuff...
I already did some quests for killing a wolf but I cannot do a HP system to lose Health and heal after a battle or a hunt.
I'll appreciate if someone help me

Comments
hotnewtop
Profile icon
Highwayman
health = 100 # is a global variable. def wolf_dmg(): health = health - 32 # changes the global value 'health'. return health def heal(): health = health + 100 # changes the global value 'health' return health print("damaged! Health is now ", wolf_dmg()) print("healed! Health is now ", heal())
Profile icon
yBen2201

@Highwayman It didn't work

Profile icon
yBen2201

@Highwayman It says "Local variable 'health' defined in enclosing scope on line 1 referenced before assignment"

Profile icon
Highwayman

🤷‍♂️ I don’t really use python that much. Idk. @yBen2201

Profile icon
Spacecraft

This should be posted in ASK, not the TUTORIALS section.