#It doesn't destroy the tree

19 messages · Page 1 of 1 (latest)

neat field
#
local Axe = script.Parent.Handle.Axe.Something
local Hm = script.Parent
local health = 100
local tree = game.Workspace.tree

Axe.Touched:Connect(function(hit)
    if hit.Parent.Name == tree then
        health = health - 30
        if health <= 0 then
            tree:Destroy()
        end
    end
end)```

It doesn't do what I write here idea of script is there variable health when it touched tree hit used then health will lose 30 and if it 0 destroy
#

Alright

#

Didn't work

#

Hm it means there wrong at hit

#

Here's picture of parents and everything

unreal tendon
#

actually

#

nvm

#

How many parts does your tree have or is it just one part

neat field
#

I do

#

Still

dusky trail
neat field
dusky trail
#

did u try use the touched event on the axe or the handle?

neat field
#

The tool

neat field
ember tundra
#

local Axe = script.Parent.Handle.Axe.Something
local Hm = script.Parent
local health = 100
local tree = game.Workspace.tree

Axe.Touched:Connect(function(hit)
if hit.Parent.Name == tree.Name then
health = health - 30
if health <= 0 then
tree:Destroy()
end
end
end)