RedHairedHero Posted February 12, 2017 Share Posted February 12, 2017 Hello, I'm attempting to create a basic counter when the user attacks a creature, however it seems to not go up at all. The current function is... local function onattack(inst) local counter = 0 counter = counter + 1 return counter end I know it's setting it to 0 every time the onattack happens so there's something wrong with the return, any help would be appreciated. Link to comment https://forums.kleientertainment.com/forums/topic/73978-basic-counter-onattack/ Share on other sites More sharing options...
Lumina Posted February 12, 2017 Share Posted February 12, 2017 Maybe put the counter outside of "onattack" because everytime you'll attack it'll be reset to 0 ? Sorry if it's stupid, i'm not sure about what return is supposed to do. Link to comment https://forums.kleientertainment.com/forums/topic/73978-basic-counter-onattack/#findComment-865932 Share on other sites More sharing options...
RedHairedHero Posted February 12, 2017 Author Share Posted February 12, 2017 (edited) 6 hours ago, Lumina said: Maybe put the counter outside of "onattack" because everytime you'll attack it'll be reset to 0 ? Sorry if it's stupid, i'm not sure about what return is supposed to do. Hmm I could give that a try, perhaps putting the counter = counter + 1 inside the onattack and the counter = 0 somewhere else. I'm honestly not sure about return either, I thought it would just return the result for counter so it would loop. Edit: That did the trick counter = 0 is added outside of the onattack function and counter = counter + 1 is added to the onattack function, return counter was not needed to achieve this. Thanks for the input, it's always the simple answer that gets me. Edited February 12, 2017 by RedHairedHero Link to comment https://forums.kleientertainment.com/forums/topic/73978-basic-counter-onattack/#findComment-866010 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