local MyParams1 = RaycastParams.new() -- ray 1 parameters
MyParams1.FilterDescendantsInstances = {ObjectsToIgnore, char}
MyParams1.FilterType = Enum.RaycastFilterType.Blacklist
local BulletResult1 = workspace:Raycast(Origin, Direction.Unit * 500, MyParams1)
if BulletResult1 and BulletResult1.Instance then -- if ray 1 hit a wall (basically if your bullet hit a wall, then)
local MyParams2 = RaycastParams.new() -- Ray #2 parameters
MyParams2.FilterDescendantsInstances = {ObjectsToIgnore, char, BulletResult1.Instance} -- make the 2nd ray ignore wall which the bullet is shot at
MyParams2.FilterType = Enum.RaycastFilterType.Blacklist
local BulletResult2 = workspace:Raycast(Origin, Direction.Unit * 500, MyParams2) -- cast out 2nd ray
if BulletResult2 and BulletResult2.Instance then -- if 2nd ray hits something, then
-- stuff
end
end
This is a simplified version of my script. It shoots out a first ray, then shoots out a 2nd ray which ignores whatever the first ray hit. The first ray works just fine, but the 2nd ray seems to point slightly downwards. The closer the first ray is towards the wall, the more the 2nd ray points downwards
The direction is the exact same and was never changed between the 2 rays