Mouse Cannot Detect Parts With Other Collision Groups

The players mouse cannot detect any part without the collision group “default”. Is there any workaround to this

The only workaround I know of is raycasting from the camera’s position towards the mouse, otherwise there’s no way to directly change the mouse’s collision group.

1 Like

It is not possible to change the raycast that detects Mouse.Target. It will always use the Default collision group, which means all collision groups that do not collide with it will be ignored. If a collision group is collidable with Default, then it is considered in default raycast.
However, you can do your own raycast by using the Mouse.UnitRay to get origin and direction, then using it in WorldRoot:Raycast() and specifying your own CollisionGroup in RaycastParams:

local ray = Mouse.UnitRay
local distance = 200
local params = RaycastParams.new({}, Enum.RaycastFilterType.Exclude, true, "CollisionGroup", true)
local result = workspace:Raycast(ray.Origin, ray.Direction * distance, params)
if result then
	local target = result.Instance
	-- use target
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.