local debounce = false 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 hitsneeded = 4 b.Touched:connect(function(hit) if not debounce then debounce = true debounce = false end if hit.Parent.Name == "Basic Axe" then hits = hits + 1 if hits == hitsneeded 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 tree should fall once it reaches 4 hits, but it falls on the first hit which i touch it with the Basic Axe. I was told to add a debounce so I did, still the same thing happens. If I put the "debounce = true" line after the "hits = hits + 1" line, the whole script fails to work and the tree doesn't fall at all. Maybe it's not a problem with the debounce, maybe the script has a problem with the hitsrequired variable and just follows the rest of the script causing the tree to fall?
If you're using a debounce, you wanna make it look something like this:
local debounce = false 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 hitsneeded = 4 b.Touched:connect(function(hit) if not debounce then if hit.Parent.Name == "Basic Axe" then debounce = true hits = hits + 1 if hits >= hitsneeded 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 wait(1) -- You can change this to the time between each axe swing debounce = false end end end)
I may be wrong, please correct me if I am. Have fun scripting!