local MouseTarget = Mouse.Target
Mouse.TargetFilter = {}
if MouseTarget.Name == "Handle" and MouseTarget ~= nil then
Mouse.TargetFilter = table.insert(Mouse.TargetFilter,MouseTarget)
print(MouseTarget)
print(Mouse.TargetFilter)
end
As stated the “MouseFilter” property can only be assigned a single instance as its value (Model, BasePart etc.) but remember that all of the descendants of the specified instance are filtered as well, such that if you were to do the following.
Mouse.TargetFilter = Model
The model itself is blacklisted by the mouse with all of its contained descendants. If you want to filter multiple instances (but not their contained descendants) which perhaps do not share the same DataModel hierarchy (ancestry) then you can use the following workaround.
local Part1 = workspace.Part1
local Part2 = workspace.Part2
local function randomFunction()
if Mouse.Target == Part1 or Mouse.Target == Part2 then --If the mouse's target matches one of these blacklisted instances then return out of the function immediately.
return
else
--Run code as usual if the mouse's target is not blacklisted.
end
end
and finally, if you want to blacklist (filter) multiple instances (and their contained descendants) which perhaps do not share the same ancestry then you can use the following workaround.
local function randomFunction()
if Mouse.Target:FindFirstAncestor("Model1") or Mouse.Target:FindFirstAncestor("Model2") then --If the mouse's target is a descendant of one of the blacklisted instances then return out of the function immediately.
return
else
--Run code as usual if the mouse's target is not a descendant of one of the blacklisted instances.
end
end