Bullets go through wall on ricochet (fastcast)

im trying to fix my ricochet code to not make the bullet go through the wall after bouncing off using the ray pierced event from fastcast

video:

code:

local function Reflect(surfaceNormal, bulletNormal)
	return bulletNormal - (2 * bulletNormal:Dot(surfaceNormal) * surfaceNormal)
end

function RayPierced(cast, result, velocity, bullet)
	local position = result.Position
	local normal = result.Normal

	local newNormal = Reflect(normal, velocity.Unit)
	
	cast:SetVelocity(newNormal * velocity.Magnitude)
	cast:SetPosition(position)
end

is there anyway to make it no go through the wall?

1 Like

I think it’s just the bullet trail becouse in the video you can see the trail going behind the player when shooting

1 Like

there is no trail its one bullet and im trying to fix it not going through the wall in the video not shooting behind the player