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.
local Tool = script.Parent.Parent
swing1 = Tool:FindFirstChild("attackState1")
swing2 = Tool:FindFirstChild("attackState2")
aerial = Tool:FindFirstChild("aerialstate")
boxActive = Tool.boxActive
hurt = script.Parent.damage.Value
local function onTouched(hit)
while boxActive.Value == true do
if hit.Parent:findFirstChild("Humanoid") then
hit.Parent["Humanoid"]:TakeDamage(hurt.Value)
wait()
end
end
local function hurtcalc()
if aerial.Value == true then
hurt.Value = 10
print "damage 10"
return hurt.Value
elseif swing1.Value == true then
hurt.Value = 20
print "damage 20"
return hurt.Value
elseif swing2.Value == true then
hurt.Value = 15
print "damage 15"
return hurt.Value
end
script.Parent.Touched:Connect(onTouched)
end
end
script.Parent:GetPropertyChangedSignal("Transparency"):Connect(hurtcalc)
