sgoodwin93 Posted July 19, 2015 Share Posted July 19, 2015 I'm trying to make a character that regains health and sanity either with every hit or when he kills an enemy.I'm struggling pretty hard and my game keeps crashing. Does anyone know a good (working) code to make this happen? Link to comment https://forums.kleientertainment.com/forums/topic/56307-health-and-sanity-regen-in-combat/ Share on other sites More sharing options...
Blueberrys Posted July 19, 2015 Share Posted July 19, 2015 @sgoodwin93 Log to help you with crashes. Code.local function regen(inst, amt) inst.components.health:DoDelta(amt) inst.components.sanity:DoDelta(amt)end-- When you attack somethinginst:ListenForEvent("onhitother", function(inst, data) regen(inst, 5) end) -- When you kill somethinginst:ListenForEvent("killed", function(inst, data) regen(inst, 10) end) Link to comment https://forums.kleientertainment.com/forums/topic/56307-health-and-sanity-regen-in-combat/#findComment-655718 Share on other sites More sharing options...
sgoodwin93 Posted July 19, 2015 Author Share Posted July 19, 2015 It works! That is so much simpler than what I was trying to do. Thank you!It works! That is so much simpler than what I was trying to do. Thank you! Link to comment https://forums.kleientertainment.com/forums/topic/56307-health-and-sanity-regen-in-combat/#findComment-655764 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now