I want to make a tree that falls apart upon being touched by a humanoid.
But I can’t seem to figure it out, and I have no idea what the issue is.
I haven’t tried any solutions as because I don’t know what would solve this the code seems fine
local base = script.Parent
local model = base.Parent
local descendants = model:GetDescendants()
local players = game:GetService(“Players”)
local debris = game:GetService(“Debris”)
local debounce = false
base.Touched:Connect(function(hit)
if debounce then
return
end
local character = hit.Parent
local human = character and character:FindFirstChildWhichIsA("Humanoid")
if human then
debounce = true
for _, descendant in pairs(model:GetDescendants()) do
if descendant:IsA("BasePart") then
descendant.Anchored = false\
debris:AddItem(descendant, 20)
end
end
end
end)
