Collecting an item?

  1. What do you want to achieve? When my axe chops a tree, I want it so that it can be collected when Anchored = false

  2. What solutions have you tried so far? I have looked tutorials on how to chop trees but none of them said how the tree can be collected after you touch it.

My current code for chopping the tree

local z = script.Parent
local x = z.Log
local y = z.Leaves
local hits = 0
local hitsN = 3
x.Touched:connect(function(hit)
	if hit.Parent.Name == "Axe" then
		hits = hits + 1
		
		if hits == hitsN then
			hits = 0
			x.Anchored = false
			y.Anchored = false
			y.CanCollide = false
			wait(3)
			hit:Destroy()
			x.Rotation = Vector3.new(45,0,0)
		end
	end
end)

I have another issue. When I chop my tree, my axe disappears and is no longer able to be used. How do I make it so that it’s usable all the time?

Have you tried CSG Service?

Is that for the collection or axe issue?

It should be for the axe issue.

Well what about using a touched event, or a click event, maybe that can be used for collecting an item (I recommend a clicked event)
Also in the script you’re saying hit.Destroy() with the axe being parented to hit.Parent

1 Like

I have a touched event but I don’t know how to apply it when x.Anchored = false

Maybe try an If statement, checking for it to not be anchored.

x.Anchored = false
if x.Anchored == false then
     -- The part of the script dealing with picking up the item
end
1 Like