Script not working

hi there, thanks for clicking here, i have one problem with script. its about randomly spawning parts on the map but its not working. Script location; ServerScriptService Code:

`local desiredTrees = 100
local TreeModel = game.Workspace.Wood

for i = 1, desiredTrees, 1 do
wait()
local wood = TreeModel:Clone()
wood.Parent = workspace
local Height = 5
wood.PrimaryPart = wood.MeshPart
wood:SetPrimaryPartCFrame(CFrame.new(Vector3.new(math.random(-157, 249),Height, math.random(-157, 249))))
for i, v in pairs(wood:GetDescendants()) do
	if v:IsA("BasePart") then
		for ii, vv in pairs(v:GetTouchingParts()) do
			if wood and not vv:FindFirstAncestor(wood) then
				wood:Destroy()
				break
			end
		end
	end
end

end`

1 Like

What’s not working about it? Are there any errors?

1 Like

no errors, nothing. just not working

Put a print statement after wood:Destroy(), the tree might be destroying itself as soon as it places.

1 Like

but if i do so it’ll spam print 100 times

edit; it doesnt work at all it shows error edit2; it actually does spam 100 prints

Can you please provide some more context as to what’s not working?

literally nothing happens, also print() works, doesnt spawn trees edit; i found out reason, it self deletes instantly