Post your whole code, not just snippets. It might be easier to use paste.wowace.com or pastey.net so we can download the file. I might have introduced a bug by the location I chose to declare your variables locally, but unless I can see the whole code, there is no way to be certain.
Assuming your code is all you want this to do, then don't use Ace3; which you aren't even using right now, actually. At least not properly. Line 3 should not be local, and the variable critChance is only visible to that function because you defined it as local to that function.