Delete other parts based on name

Okay, then add an if statement. What part do you want to touch the grass and what is the part named?

it is named grass cutting part

Okay, so still put the grass into a folder, and then put a script into the folder that says this:

local Parts = script.Parent:GetChildren()

for I,v in pairs(Parts) do
   v.Touched:Connect(function(hit)
     if hit.Name == "GrassCuttingPart" then --Make sure that GrassCuttingPart is written correctly
       v:Destroy()
     end
   end)
end
2 Likes

thanks, this works better than the other ones people gave me as this is specific to the one part that can cut grass. The only problem is the lag.

1 Like

No problem, not sure about the lag… but glad the script works!

1 Like

This is an inefficient solution, you’re connecting a function to potentially hundreds/thousands of individual parts. The solution I provided above is essentially the same but you’re only connecting a function to the grass cutting part itself.

local part = script.Parent

part.Touched:Connect(function(hit)
	if hit.Name == "Grass" then --some name
		hit:Destroy()
	end
end)

“local part” would be the handle of the tool which is cutting grass.

1 Like

Where should i put this script then?