Detect part with CanQuerry set to False

Setting canquerry to false helps improve performance of games with a but ton of parts which is why I have parts that have can collide, can touch and canquerry set to false, although I still want the player to be able to collide with these parts

The way I think about going with this is to check all parts bound in radius and make them collidable but of course that won’t work and I can’t seem to find a single good solution to this

Comment anything you know, I need a solution and I bet 2000 others also do :eye: :lips: :eye:

1 Like


Create a script in ServerScriptService and try this:

function Touched(Part:Part): {Instance}
	local params =
	params.FilterDescendantsInstances = {}
	params.FilterType = Enum.RaycastFilterType.Exclude
	local Parts = workspace:GetPartBoundsInBox(Part.CFrame, Part.Size, params)
	return Parts

local part = workspace:FindFirstChild("Part")

while wait() do
	local Parts = Touched(part)
	for _,hit in pairs(Parts) do
		--//if you need to get a player
		if game.Players:GetPlayerFromCharacter(hit.Parent) then
			local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
			print(plr.Name.." Touched Part")
1 Like

Doing that would actually result in worse performance than if you kept CanCollide set to true

What people mean when they say to turn off CanCollide, CanQuery and CanTouch is for parts that don’t need them to be on, as an example:

  • If you’re not using the part’s Touched or TouchEnded events, then CanTouch can be set to false
  • If the part is very small like a crumpled up piece of paper or a flower, then CanCollide doesn’t need to be set to true
  • If the part has CanCollide set to false and you don’t want raycasts to detect it, then turn off CanQuery

If you’re experiencing lag due to many parts within your game, then consider grouping them together into meshes using something like Blender

I also recommend you read this docs article to learn more about how to optimize:

@RobloxTim2001 Also, consider using streaming:

It helps quite a lot for games with large maps, but will require you to code a bit differently since Instances will no longer be guaranteed to be present on the client even after they’ve finished loading

This is a very bad idea. To do this, you’d most likely have to perform a function such as workspace:GetPartBoundsInBox() to detect if the character is intersecting a part’s hitbox on every step, which is very performance-heavy. Instead, I suggest you do the following:

  1. Set CanCollide, CanTouch, and CanQuery to false for all parts that do not require collision or raycast interactions, such as small decorations.

  2. Unfortunately, CanQuery cannot be disabled while CanCollide is set to true. If you want a raycast to ignore a part, while still maintaining it’s collisions, filter them out using RaycastParams

  3. If you want to improve performance, workspace.StreamingEnabled is a great solution that does not require any custom rendering code.

Content Streaming is certainly the way to go, and I would specifically recommend modifying the model’s Level of Detail. When the player walks a certain distance away, this property will convert the model into a look-alike mesh that isn’t as resource heavy as the original BaseParts.

Sorry for replying to everybody so late but I can see that everybody’s recommending streaming. I’ll play around with the settings but I’m sure it will still lag a lot . I will be replying back after the results : )