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
Create a script in ServerScriptService and try this:
function Touched(Part:Part): {Instance}
local params = OverlapParams.new()
params.FilterDescendantsInstances = {}
params.FilterType = Enum.RaycastFilterType.Exclude
local Parts = workspace:GetPartBoundsInBox(Part.CFrame, Part.Size, params)
return Parts
end
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")
end
end
end
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:
Set CanCollide, CanTouch, and CanQuery to false for all parts that do not require collision or raycast interactions, such as small decorations.
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
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 : )
My script sucks, yes streaming did help a little, I looked and tried every single suggestion but it did not magically fix the problems. Thank you all for helping me, and for anyone looking for how to detect parts with CanQuerry set to false its simply impossible using the traditional ways. The only way I can come up with is having the parts stored inside an array there if said distance was to be as an example 20 studs away you enable CanQuerry but that would maybe worsn’ the performance