Need help with my tree cutting system

Hi,

So I would like to adjust the tree script I bought. I want the tree to slightly bounce and then disappear. The script includes a regrowth.

This is the script in the tool. You can find the code here:

local Tool = script.Parent
local Handle = Tool.Handle


local Connect

local Debouce = true
local TreeChops = 0
local Respawning = false

local TweenService = game:GetService("TweenService")
local part = script.Parent

function CreateTween(Stump,Goals,KeepUnder)
	
	local Info = TweenInfo.new(
		0.1,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.InOut,
		0, 
		KeepUnder, 
		0 
	)

	local tween = TweenService:Create(Stump,Info,Goals)
	tween:Play()
	
end

Tool.Activated:Connect(function()

	if Debouce then	

		Debouce = false

		Connect = Handle.Touched:Connect(function(Hit)

			if (Hit.Parent.ClassName == "Model") then 
				
				local Stump = Hit.Parent:FindFirstChild("Stump")
				
				if Stump then
					
					local Goals = { Position = Stump.Position + Vector3.new(0,2,0) }

					TreeChops += 1; 

					CreateTween(Stump,Goals,true)

					warn("Found Tree Model (" .. TreeChops ..")") 
					
					if Respawning and TreeChops >= 3 then

						local Goals = { Position = Stump.Position + Vector3.new(0,-20,0) }

						CreateTween(Stump,Goals,false)
						
						local Leaderstats = game:GetService("Players"):GetPlayerFromCharacter(Tool.Parent):FindFirstChild("leaderstats")

						if Leaderstats then

							local Wood = Leaderstats:FindFirstChild("Wood")

							Wood.Value += 3

						end

						return

					end
					
					if not Respawning and TreeChops >= 3 then
						
						Respawning = true
						
						task.spawn(function()
							
							for Seconds = 0,10,1 do
								
								wait(1)
								
							end
							
							wait(10)
							
							warn("Respawning..")
							
							TreeChops = 0;

							local Goals = { Position = Stump.Position + Vector3.new(0,20,0) }

							CreateTween(Stump,Goals,false)

							return

						end)
						
					end

					Connect:Disconnect() 
					
				else
					
					Connect:Disconnect()
					
					warn("This isnt a tree.")
					
				end
				
			end

		end)

		wait(2)

		Debouce = true


	end
	

end)
1 Like

Bumping this post, does anyone know the answer? :slight_smile:

1 Like

Instead of bouncing and disappearing what does it do?

2 Likes

it collapses and does not respawn.

Iā€™m bumping this post, can someone please help?