Script help with Clone

The Script:

while wait(1) do
local DistanceFromPart = (script.Parent.Position - plr.Character:WaitForChild(“HumanoidRootPart”).Position).magnitude
if 15 > DistanceFromPart then

		if not script.Parent:FindFirstChild("TreeHealth") then
			TreeHealthGui.Parent = script.Parent
		end
		

		
	elseif 15 < DistanceFromPart then	
		if script.Parent:FindFirstChild("TreeHealth") then
			script.Parent.TreeHealth:Destroy()
		end
end	

end

this error pops up when i move away from the item and come back

the error: The Parent property of TreeHealth is locked, current parent: NULL, new parent Tree

you are destroying script.Parent.TreeHealth:Destroy() and then trying to reparent it. thats why the error is popping up.

if you want to reuse it, instead of destroying it. try making it parent to nil instead.

while wait(1) do
local DistanceFromPart = (script.Parent.Position - plr.Character:WaitForChild(“HumanoidRootPart”).Position).magnitude
if 15 > DistanceFromPart then
	if not script.Parent:FindFirstChild("TreeHealth") then
		TreeHealthGui.Parent = script.Parent
	end
	elseif 15 < DistanceFromPart and script.Parent:FindFirstChild("TreeHealth") then	
	      script.Parent.TreeHealth = nil
     end	
end
end