I'm having a bit of trouble seeing what exactly is wrong with my script. It looks completely fine to me but it doesn't work because I can't get the function to fire off because it says that my function (hurtcalc) is apparently not defined.
Here is the code (it's a globalscript) and thank you in advance for helping me.
01 | local Tool = script.Parent.Parent |
02 | swing 1 = Tool:FindFirstChild( "attackState1" ) |
03 | swing 2 = Tool:FindFirstChild( "attackState2" ) |
04 | aerial = Tool:FindFirstChild( "aerialstate" ) |
05 | boxActive = Tool.boxActive |
06 |
07 | hurt = script.Parent.damage.Value |
08 |
09 |
10 |
11 | local function onTouched(hit) |
12 | while boxActive.Value = = true do |
13 | if hit.Parent:findFirstChild( "Humanoid" ) then |
14 | hit.Parent [ "Humanoid" ] :TakeDamage(hurt.Value) |
15 | wait() |
You have misplaced end
keywords. So your hurtcalc
is actually local to the definition of onTouched
, where it doesn't get used or called, and then hurtcalc
is out of scope at the last line of the script.
Add another end
after the onTouched
logic, and remove one end
after the hurtcalc
logic.