[Post is Outdated]

You could use RaycastParams.

local params = RaycastParams.new() -- new params
params.FilterType = Enum.RaycastFilterType.Exclude -- setting they type to Exclude
params.FilterDescendantsInstances = {WallsFolder} -- All descendants of WallsFolder are being set to filter type

local Ray = workspace:Raycast(..., ..., params)

new code:

local RunService = game:GetService('RunService')

local Camera = script.Parent
local Range = 20

RunService.Stepped:Connect(function()
    local Params = RaycastParams.new()
    Params.FilterType = Enum.RaycastFilterType.Exclude
    Paramsl.FilterDescendantsInstances = {wallsFolder} -- switch this

	local Raycast = game.Workspace:Raycast(Camera.Position, Camera.CFrame.LookVector * Range, Params)

	if Raycast ~= nil then
		if Raycast.Instance.Parent:FindFirstChildOfClass('Humanoid') then
			print('Detected!')
		end
	end
end)

Interesting that should have worked.

try debugging by printing result instance before searching for humanoid

if Raycast then
	print(Raycast.Instance)
end
1 Like

could you show your current code

My bad using filter type won’t help at all. Use the original script:

local RunService = game:GetService('RunService')

local Camera = script.Parent
local Range = 20

RunService.Stepped:Connect(function()
	local Raycast = game.Workspace:Raycast(Camera.Position, Camera.CFrame.LookVector * Range)

	if Raycast ~= nil then
		if Raycast.Instance.Parent:FindFirstChildOfClass('Humanoid') then
			print('Detected!')
		end
	end
end)

Look at the wall part and see if the canQuery property is off.

ok is that a server script under a Camera part in workspace?

For me your script works.

chars

could you add me to team create because im confused lol

oh so i need to join to your group?