Your code is only checking the health once. The script reads what you've written up to tree.Touched:connect... once and then just listens for the tree being touched, every time the tree is touched the code in that funciton runs. So just have the script check the health everytime the tree is touched :)
local tree = script.Parent
local health = 10
tree.Touched:connect(function(hit)
if hit.Name == "Blade" then
health = health - 1
print("Player Has Cut Tree")
if health == 0 then
tree.Position = CFrame.new(tree.Position) + Vector3.new(-52.751, 50.888, -54.404))
else print(health)
end
end
end)
Hopefully that is clear and works alright... :)
Best of luck, let me know if this helped!
3 comments
Try to use tree.Position = Vector3.new(-52.751, 50.888, -54.404) Instead
still wont work.
Have u tried to used a int or numbervalue as its health and change it when its touched, then link it up with a changed event or something?