So I need the rays to ignore the bullets, but there is an issue where the raycast is not ignoring the bullets being made. The solutions I tried so far are Mouse.TargetFilter, and RayCastParams.FilterDescendantsInstances.
After some testing I realized that the raycast does not ignore the instance if there are other instances with the same name. How can I prevent that?
Here is the part of the script I am trying to solve.
local bullet = ServerStorage.Things.Bullet:Clone()
local rayCastParams = RaycastParams.new()
rayCastParams.FilterDescendantsInstances = {player.Character, bullet, shoot_part, tool.BodyAttach, nil, tool.Parts["Colt _Python"]}
rayCastParams.FilterType = Enum.RaycastFilterType.Blacklist
local origin = shoot_part.Position
local direction = (position - origin).Unit*300
local result = Workspace:Raycast(origin, direction, rayCastParams)
local intersection = result and result.Position or origin + direction
local distance = (origin - intersection).Magnitude
local x = math.random(-spread*100,spread*100)/100
local y = math.random(-spread*100,spread*100)/100
print(x,y)
bullet.Name = "Bullet"
bullet.Size = Vector3.new(0.1, 0.1, distance)
bullet.CFrame = CFrame.lookAt(origin, intersection)*CFrame.new(0, 0, -distance/2)*CFrame.Angles(math.rad(x),math.rad(y),0)
bullet.Parent = game.Workspace.Bullets
Maybe instead of parenting the bullets to the workspace, parent the bullets to a folder named “Bullets” that is in the workspace. Then one of the blacklists parameters could be:
I would try adding the bullets to a folder and ignoring all descendants in that folder. FilterDescendantsInstances table will only ignore all descendants of the objects in the table, and not the instance itself, this is why your current code isn’t working.
Oh, thank you for informing me. It now ignores the bullets. XdJackyboiiXd21 solution almost worked but the only thing that didn’t make it work is the :GetChildren(). Thank you for your efforts guys.