Help with Bullet Hole going through certain amount of walls, Penetration

Hello my name is Mark, I am trying proceed at making a penetration system for my FirstPersonShooter game this is the following line of code sorry if is all scrambled but I’ve been trying this for about a week:
for i,pa in pairs(workspace:GetChildren()) do
if pa:IsA(‘Part’) then
buh.Touched:Connect(function(h)
local hi = pa

				function penetrate()
					local db = true
					if db then
						db = false
						
					
						local d = (buh.Position - hi.Position).magnitude*2
						local rp = RaycastParams.new()
						rp.FilterDescendantsInstances = {buh}
						rp.FilterType = Enum.RaycastFilterType.Blacklist
						local RR = workspace:Raycast(buh, d, rp)
						buh.CFrame = CFrame.new(script.Parent.Model.Barrel.Position, m) * CFrame.new(0, 0, d)
					end
				end
				
				function nopenetrate()
					local db = true
					if db then
						db = false

						
						
					end
				end
			
			
				if hi then
					if hi.Size.Z > 1 then
					print('did not penetrate.')
					nopenetrate()
				else
					print('penetrated')
					penetrate()
					end
				end
			
				
			end)
		end
	end