durabilityInteger = 100

function checkTreeGrowth()
	if game.Workspace:FindFirstChild("Tree") == nil then
		game.ReplicatedStorage.Tree:Clone().Parent = workspace
	end
end

while game.Workspace:FindFirstChild("Tree") == nil do
	wait(3) -- I just added this. Only adds it after 3 second in the start though..
	checkTreeGrowth()
end
	


function treeFeller(player)
	durabilityInteger = durabilityInteger - 25
	print(durabilityInteger)
	if durabilityInteger == 0 then
		game.Workspace.Tree:Destroy()
	end
end

game.Workspace.Tree.hitterDet.ClickDetector.MouseClick:Connect(treeFeller)
										

Even after the cloned tree from ReplicatedStorage destroyed, the while loop did not execute again. No errors in the output or script analysis. I just started learning Roblox Studio scripting from my own knowledge. (For your information, I did not copy this.)

The purpose of this, I wanted to create a tree after that the Player had chopped down and it went to their inventory. For now, I require no help with the inventory problem since I want to create it by myself. After the tree is chopped, the tree will remain dormant for a moment but then it will come back.

3 comments

0

Okay, I can probally see your error. But first, I need some questions. Is this a script or local script, and where is this code at? Also, where is the tree at. Awnser theese, and I will post an awnser for you

0

This is a script. A normal script, placed directly inside the Workspace.

0

And you can tell by the code where the tree is at. A model, of course.