I have made a chop-able tree script and it works, sort of.
local a = script.Parent local b = script.Parent.Log local c = script.Parent.Log2 local d = script.Parent.Log3 local e = script.Parent.Log4 local f = script.Parent.Leaves local g = script.Parent.Leaves2 local h = script.Parent.Leaves3 local i = script.Parent.Leaves4 local hits = 0 local hitsN = 16 b.Touched:connect(function(hit) if hit.Parent.Name == "Basic Axe" then hits = hits + 1 if hits == hitsN then hits = 0 b.Anchored = false c.Anchored = false d.Anchored = false e.Anchored = false f.Anchored = false g.Anchored = false h.Anchored = false i.Anchored = false f.CanCollide = false g.CanCollide = false h.CanCollide = false i.CanCollide = false end end end)
the "local hitsneeded" is setting the hits needed to 16 so that once the tree has been hit 16 tims, all leaves will fall and the logs will become unanchored, but for some reason, the tree falls the first time that i hit the tree. I hit the tree with the "Basic Axe" tool i have in my inventory and it crumples on the first hit instead of sixteenth, can i get some help? thanks :)
Are you sure that all the 16 hits don't happen in quick succession? It's possible that when you hit the tree it triggers the command 16 times because there is no wait intervals between when it can be hit, so it is allowed to land the second hit milliseconds after the first. Try this http://wiki.roblox.com/index.php?title=Debounce
A nice way to fix this would be with a debounce (http://wiki.roblox.com/index.php?title=Debounce), since it seems to me that it's repeatedly adding one to your variable, as you are using "Touched:connect". Another way is to use a click detector. Have fun coding!