I'm having a similar problem, although I technically could model the things together, I don't want to, because that could cause me issues later in developing. My answer is pretty similar to guges' answer, and so, building off of his code:
local function addToNewModel(bin, models)
local model = Instance.new("Model", bin)
previousPaths = {}
for modelId, v in pairs(models) do
previousPaths[modelId] = {v.Parent,v.Name}
v.Name = tostring(modelId)
v.Parent = model
end
return model, previousPaths
end
local function returnToPaths(bin, previousPaths)
for _, v in pairs (bin:GetChildren()) do
modelId = tonumber(v.Name)
v.Parent = previousPaths[modelId][1]
v.Name = previousPaths[modelId][2]
end
end
(Please note, I haven't actually tested this, as I write, so there may be errors, but hopefully, you get the idea!)
And example usage would be as follows:
local function FilteredTarget(bin, filterTable, mouse)
local model, previousPaths = addToNewModel(bin, filterTable)
mouse.TargetFilter = model
target = mouse.Target
returnToPaths(bin, previousPaths)
return target
end
I hope this helps (or at least that it might help inform an answer, even if I've messed up the code badly!)
2 comments
Thanks very much, i have thought of that, but 1 problem is, 1 Model is in workspace, and 1 Model is in player's Camera. So....
Well in that case I'm not sure what you could do. If you're using localparts via the camera then I recommend trying to make the switch to FE. It helps things like this massively.