Mouse.TargetFilter not working

Hello everyone, I hope you’re having a good day.

So I have a problem where I am setting mouse.TargetFilter to a part let’s say called “Part1”. I set it like this:

if part.Name == "Part1" then
mouse.Targetfilter = part
end

The problem is that when I delete that part and replace it with an exact clone with the same name, the targetFilter doesn’t ignore that part and registers it as mouse.Target even though I used the code above again on the new copy with the same name.

So I don’t know why this is happening, if anyone can help me that would be much appreciated. Thank you.

Maybe provide some more info on the script. Currently it should work unless you have 2 parts named Part1. Unless you loop between the parts.

Mouse.TargetFilter accepts a single instance. That instance and its descendants will be ignored.

If you want to add more parts to the filter which are not under the same ancestor, you should use raycasting.