Possible to delete a single part (on touch) with the same name as other parts?

Hello, I am currently working on a farming feature where you can drive the tractor over wheat which will delete the wheat part. There are hundreds of wheat parts and they are all named the same.

Is there any way I am able to make the wheat part destroy after touching that specific wheat part (with the same name as other parts)?

You could connect an touched event to the part that deletes wheat that deletes the part it touched if its name equals the wheats name

local part = --Part here
local name = --Name here

part.Touched:Connect(function(otherpart)
   if otherpart.Name ==  name then
   otherpart:Destroy()
   end
end)
1 Like

Like this?

local part = game.Workspace.WHEAT
local name = "WHEAT"

	part.Touched:Connect(function(otherpart)
	if otherpart.Name ==  name then
		otherpart:Destroy()
	end
end)
1 Like

yes, that should work if both parts can touch
wait no, part should be the one that deletes the wheat.

1 Like

Thank you so much! Huge help. l

1 Like

Mark his post as a solution post so that others know it got solved. :happy1:

1 Like