Enum.Blacklist Deprecation broke a raycast script

I opened my game that I haven’t touched in a few months, and saw that Enum.Blacklist got depreciated. So I switched to .Exclude, but now its messing with the camera even though I have it on the table that gets excluded.

Function:
(camera is a variable outside the function)

function raycast(instances)
	local mouseLocation=UserInputService:GetMouseLocation()
	local mouseRay=camera:ViewportPointToRay(mouseLocation.X,mouseLocation.Y)
	local raycastParams=RaycastParams.new()
	raycastParams.FilterType=Enum.RaycastFilterType.Exclude
	raycastParams.FilterDescendantsInstances=instances
	local raycastResult=workspace:Raycast(mouseRay.Origin,mouseRay.Direction*1000,raycastParams)
	return raycastResult
end

How it’s being inputted:

game:GetService("RunService").RenderStepped:Connect(function()
	if towerClone then
		local result=raycast({towerClone,camera})
		if result and result.Instance then
			if result.Instance.Parent.Name=="TowerArea" then
				canPlace=true
				for i,object in pairs(towerClone:GetDescendants()) do
					if object:IsA("BasePart") then
						object.Color=Color3.new(0,1,0)
					end
				end
			else
				canPlace=false
				for i,object in pairs(towerClone:GetDescendants()) do
					if object:IsA("BasePart") then
						object.Color=Color3.new(1,0,0)
					end
				end
			end
			towerClone.HumanoidRootPart.Anchored=false
			towerClone:SetPrimaryPartCFrame(CFrame.new(
				result.Position.X,
				result.Position.Y+towerClone.Humanoid.HipHeight,
				result.Position.Z
				)*CFrame.Angles(0,math.rad(rotation),0)
			)
		else
			towerClone.HumanoidRootPart.Anchored=true
		end
	end
end)
1 Like

.Blacklist and .Exclude both points to the same Enum endpoint. While .Blacklist is deprecated, they are both functionally the same for now (so I’d still recommend using .Exclude and .Include for future work).

Now here’s where I think you’re going wrong:
.FilterDescendantsInstances accepts a table.
So you should be doing
raycastParams.FilterDescendantsInstances = {instances}
Instead of
raycastParams.FilterDescendantsInstances=instances

Documentation: RaycastFilterType | Documentation - Roblox Creator Hub

1 Like

Yeppy. Mark this as the solution!

1 Like

Still the same issue. I already marked the table in the RenderStepped function. Even putting a table in both functions doesn’t make a change.

My bad - you’re right!

I found this quick solution in another thread:

game:GetService("CollectionService"):AddTag(partForCameraToIgnore,"IgnoreCamera")

source: Is there a way to get the Camera to ignore collision with specific parts? - #24 by Locard

4 Likes

Sorry for the late reply but it worked, gracias!

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