I made a axe and my function that gets called later to play the animation nothing happens when it gets called nothing happens
function hit()
local anim = script.Parent.Anim
end
The error
disconnected event because of exception
will someone please help me full script here
wait(1)
------------------------
axelvl = 2 --This is the damage given to the tree.
treeMoney = 15 --this is how much money you get for felling a tree
resettime = 2 --this is how long it takes after the axe hit a tree until it works again. Avoid setting it to 0
------------------------
Tool = script.Parent
ting = 0 --this is my debounce
function hit()
local anim = script.Parent.Anim
end
function onActivated()
if not Tool.Enabled then
return
end
Tool.Enabled = false
hit()
Tool.Enabled = true
end
function onTouched(hitt)
-- print("touched something")
if ting == 0 then
ting = 1
if hitt.Parent.Name == "Tree" then
-- print("touched tree")
user = game.Players:findFirstChild(Tool.Parent.Name) --find the player that carries the axe for later moneygiving
hitt.Parent.hit.Value = hitt.Parent.hit.Value - axelvl --deal damage to the tree
hitt.Parent.Timber.Value = hitt.Parent.Timber.Value - axelvl
if hitt.Parent.hit.Value < 1 and hitt.Parent.Timber.Value < 1 then --check if the tree is felled
user.leaderstats.Wood.Value = user.leaderstats.Wood.Value + treeMoney --add money to the dude with the axe
hitt.Parent.Timber.Value = 1 --this declares the tree "felled" and makes sure nobody else can get money from it
wait(resettime)
else
wait(1)
end
end
ting = 0
end
end
Tool.Activated:connect(onActivated)
connection = Tool.Handle.Touched:connect(onTouched)

2 comments
The name of a function doesn't matter, as long as it is called by the same name consistently.
Last time I checked their were several instances where sometimes the function used capital and sometimes didnt depending on what its contained in.