Some trouble with RaycastParams/Blacklisting

Hi. I’ve been working with some raycasting stuff right now, and they are not working as I want them to.


The blue parts represent the rays, and the noob model behind the one in front of it is having it’s ray “denied” despite me adding putting fellow noobs on a blacklist. Sorry if that doesn’t make sense.

Params setup:

InstancesToIgnore = {}
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = InstancesToIgnore

Blacklisting fellow noobs:

if ThisCard.Team.Value == "Friendly" then
	CardsToTarget = workspace.Cards.EnemyCards
	task.spawn(function()
		while Actions.Health.Value > 0 do
			wait()
			for i, c in pairs(workspace.Cards.EnemyCards:GetChildren()) do
				if not table.find(InstancesToIgnore, c) then
					table.insert(InstancesToIgnore, c)
				end
			end
		end
	end)

Raycasting Sequence:

	local RayOrigin = ThisCard.HumanoidRootPart.Position
					local RayDirection = ThisCard.HumanoidRootPart.CFrame.LookVector * 35

	local RayCastResult = workspace:Raycast(RayOrigin, RayDirection, raycastParams)

Any help is appreciated.

I think you have to update the FilterDescendantsInstances by running it again with the same table variable.

Hopefully this helps! :smile:

I don’t quite understand, could you write a code example if you can? Sorry about the inconvenience.

For the blacklisting fellow noobs, I would put the FilterDescendantsInstances after inserting noobs into the table to update its blacklist, like this.

if ThisCard.Team.Value == "Friendly" then
	CardsToTarget = workspace.Cards.EnemyCards
	task.spawn(function()
		while Actions.Health.Value > 0 do
			wait()
			for i, c in pairs(workspace.Cards.EnemyCards:GetChildren()) do
				if not table.find(InstancesToIgnore, c) then
					table.insert(InstancesToIgnore, c)
				end
			end
		end
	end)
	raycastParams.FilterDescendantsInstances = InstancesToIgnore -- Update blacklist

Unfortunately the same result, but thank you for your help :slight_smile:

image

I have a tiny feeling that it might have something to do with this though?
image
Seems like the filter type is deprecated or something, Though an error did not print; but i’m just pointing it out just in case.

I see roblox is changing a lot, they just removed Blacklist and stuff, and are left with Include and Exclude. Exclude being the new blacklist and Include being the new whitelist.

I tried Exclude too. Same result unfortunately.

I think I should’ve moved the FilterDescendantsInstances before the table.insert, like this:

if ThisCard.Team.Value == "Friendly" then
	CardsToTarget = workspace.Cards.EnemyCards
	task.spawn(function()
		while Actions.Health.Value > 0 do
			wait()
			for i, c in pairs(workspace.Cards.EnemyCards:GetChildren()) do
				if not table.find(InstancesToIgnore, c) then
					table.insert(InstancesToIgnore, c)
					raycastParams.FilterDescendantsInstances = InstancesToIgnore -- Update blacklist
				end
			end
		end
	end)

You are checking if a Card is friendly, but you are blacklisting the enemies?

Well now I feel ridiculous, lol. But this was the solution, Thank you!

1 Like

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