I agree with this reply.
Currently I have a Coin Generator that covers a map, currently it’s too hard to determine which Part is a floor, and which is a roof. It would be very beneficial for me and builders to disable CanQuery without disabling CanCollide because obviously I don’t want players jumping out of / falling into buildings through the roof.
I also want / need RayCast to ignore my invisible map barricades.
Limiting our ability to use this new property by tying it to a different one is bad design, CanQuery is less usable in it’s current state.
Have you tried it before because It’s a pain to use and I wouldn’t recommend it to anyone.
Especially for @fighterbuilder’s use case. They have to constantly add new BaseParts into workspace which the IgnoreList you suggested doesn’t update (Immutable) and will cause problems and complications. By simply allowing us to use CanQuery without any restrictions would be a lot easier and starter friendly.
Here’s the hacky code I have to use to get achieve what I want for my game
local WorldRootIgnoreLists = {}
local function getIgnoredPartsForWorldRoot(worldroot: WorldRoot)
if not WorldRootIgnoreLists[worldroot] then
local IgnoredParts = {}
for _, descendant: Instance in ipairs(worldroot:GetDescendants()) do
if descendant:IsA("BasePart") then
local BasePart: BasePart = descendant
if not BasePart.CanCollide or BasePart.Transparency == 1 then
if not CollectionService:HasTag(BasePart, "Raycast_WHITELIST") then
table.insert(IgnoredParts, BasePart)
end
end
end
end
WorldRootIgnoreLists[worldroot] = IgnoredParts
end
return WorldRootIgnoreLists[worldroot]
end
local function handleIgnoredPartsForWorldRoot(worldroot: WorldRoot)
if not WorldRootIgnoreLists[worldroot] then
local IgnoredParts = {}
for _, descendant: Instance in ipairs(worldroot:GetDescendants()) do
if descendant:IsA("BasePart") then
local BasePart: BasePart = descendant
if not BasePart.CanCollide or BasePart.Transparency == 1 then
if not CollectionService:HasTag(BasePart, "Raycast_WHITELIST") then
table.insert(IgnoredParts, BasePart)
end
end
end
end
worldroot.DescendantAdded:Connect(function(AddedDescendant: Instance)
if AddedDescendant:IsA("BasePart") then
local BasePart: BasePart = AddedDescendant
if not BasePart.CanCollide or BasePart.Transparency == 1 then
if not CollectionService:HasTag(BasePart, "Raycast_WHITELIST") then
table.insert(IgnoredParts, BasePart)
end
end
end
end)
worldroot.DescendantRemoving:Connect(function(RemovedDescendant: Instance)
if RemovedDescendant:IsA("BasePart") then
local BasePart: BasePart = RemovedDescendant
table.remove(IgnoredParts, table.find(IgnoredParts, BasePart))
end
end)
WorldRootIgnoreLists[worldroot] = IgnoredParts
end
end
function raycastUtil.Raycast(worldroot: WorldRoot, Origin: Vector3, Direction: Vector3): RaycastResult?
raycastParams.FilterDescendantsInstances = getIgnoredPartsForWorldRoot(worldroot)
return worldroot:Raycast(Origin, Direction, raycastParams)
end