How to make a "grass chopping" part

Hello, I was wondering if it was possible to make a script inside of a part that detects forever if the part is touching anything inside of a folder and if it is then it deletes it and sets a bool value called triggered to true for 2 seconds?

(I’m planning to use this script to make a grass cutting thingy)

It would also be great if you could give some examples so i could mark this topic as done

1 Like

Just make it so if the grass was touched by the part then it gets destroyed

Make a script in the grass and then write something like this

script.parent.touched:connect(function(hit)
   If hit.name == "name" then
       Script.parent:destroy()
   end
end)

The code might be wrong i wrote it on a phone

2 Likes

Yeah just change the hit.name to hit.Name because then it wont work.

2 Likes
local model = workspace.Model
local part = workspace.Part
local bool = workspace.BoolVal

part.Touched:Connect(function(hit)
	for _, v in pairs(model:GetChildren()) do
		if hit.Name == v.Name then
			part:Destroy()
			bool.Value = true
			task.wait(2)
			bool.Value = false
		end
	end
end)

This is probably the complete logic you’re looking for.

how do i make it detect if its touching grass parts though?

this makes it so that it destroys the scripts parent ( the grass cutting part ) but i would like it to destroy the part that the scripts parent touches only if its called “grass”, how do i do that?

Well you didn’t ask for that in the original post but:

local model = workspace.Model
local part = workspace.Part
local bool = workspace.BoolVal

part.Touched:Connect(function(hit)
	for _, v in pairs(model:GetChildren()) do
		if hit.Name == v.Name and hit.Material == Enum.Material.Grass then
			part:Destroy()
			bool.Value = true
			task.wait(2)
			bool.Value = false
		end
	end
end)
1 Like

Thanks alot for this, ill mark it as the solution : )