This won't work

the cast is still hitting the same instance eveen tho I add it to table I need hepl

table.insert(params.FilterDescendantsInstances, cast.Instance)
1 Like

ok I just made raycast raycast a bit further from where it hit so that it can penetreate through

3 Likes

A solution, instead of the workaround you just said, is to use the RaycastParams:AddToFilter() method, since you can’t table.insert to the filter.

params:AddToFilter(cast.Instance)
2 Likes

ok it still is colliding even after
I even printed the filter and it prints the parts it hit and I do apply params

							params:AddToFilter(cast.Instance)

so you printed the filter after using :AddToFilter and the hit instance was in there?

Did you set a RaycastParams.FilterType?
Actually, could I just see a code snippet of your raycast params and the raycast logic please? It’ll make it easier to help.

1 Like

I did not set afilter type I thought it is blackist on default

					local params = RaycastParams.new()
					params.FilterDescendantsInstances = {v.Part.Value, v.Filter.Value:GetDescendants()} -- v.Filter is custom filter forsystem
					local found = true
					
					local origin= v.Position
					
					local function Cast()
						local cast = workspace:Raycast(origin,PartLookVector*Velocity,params)	
						if cast then

							
							params:AddToFilter(cast.Instance)
							
							
						else
							found = false
						end
					end
					
					local x = 0
					repeat
						Cast()
						x+=1
						task.wait()
					until x>=v.Penetration.Value -- it's three and I checked and it makes three bullet holes yet still hits same target three times

edit: set the filter to blacklist it stil does collide

I just tried that code and it worked. Are you sure you’ve set up your params correctly? Are the ObjectValues pointing to instances that are edited on the client? Is this run on the server? Also, try using the Exclude RaycastFilterType because Blacklist is deprecated and may not behave as expected.

You also need to unpack all of those values in the sub-table to FilterDescendantsInstances.

1 Like

I changed it tto exclude it still collide

this code is ran on the client

the objects exist on server too

And you’re 100% sure they aren’t different instances? Can you set up a previousHit value that will be set to the previous raycast result and then print(cast.Instance == previousHit)?

it returns false but I can swear I am shoot at same object no matter an object I shoot at it returns to false

no matter the high penetrational it does all same instance

Then they aren’t the same instance if the evaluation statement equated to false, hence the hit instance isn’t in the filter list. Check to make sure you don’t have any duplicate instances, and any instances you don’t want to interfere with the cast (like invisible parts), turn off CanCollide and CanQuery (must turn off CanCollide to access CanQuery).

therte is abosolute no duplicated where I shot I even delete it once it delete and there’s no invisible parts that can interferee

this ant even wortyujking eityher

When you print the hit part, what does it output? Can you also try moving the hit part that gets added to the filter really far away, just so we can make sure?

I shot four times

all in same spot

image

I moved it it is same instance
on client it moved too

when I print the part it prints the same part every time

my guess is all those parts have the same name, that does not mean they are the same part.

well I made sure that it penetrated three times and hit the baseplate on the third to second penetration and yet it hit the same part, and from the red highlights I put them at the cast.Position and each time they’re in same spot

you’re not changing origin at all during your cast, or any of the other values, which means they will be the same for all of them. Is that intentional?

yes and the filter should prevent the raycast from hitting the same part but it hits same part

Once again, it’s not the same part. Just to confirm this, try:

print(table.find(params.FilterDescendantsInstances, cast.Instance) ~= nil)