Trouble with Part:Destroy()

I’m currenetly making a system which destroys the selected part upon pressing e on the trash bin, however when I use it I get this error;

 Highlight is not a valid member of MeshPart "Carrot"  -  Client - localHandler:128

Solved!!!

Replace if part and part.Highlight then with if part and part:FindFirstChild("Highlight") then

Doing part.Highlight will throw an error if it does not exist, unlike FindFirstChild which will return nil.

1 Like

I’m such an idiot.
I was doing the check for part and part.Highlight inside of the function :cry:
Fixed code;

if part and part:FindFirstChild("Highlight") then
				if distance < maxDistance and direction:Dot(partDirection) > 0 then
					part.Highlight.Enabled = true
				else
					part.Highlight.Enabled = false
				end
			end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.