Hello Everyone, so I already had this problem with the bullet wall penetration. But now I have a problem. So, I have two rays that do bullet penetration, but penetration only works with parts of a small width, approximately only works with such a width as in the first image. But, for other parts with other bigger widths, it’s not working. I left the script with these rays and this system.
First Image:
Main Script: (I didn’t leave all script, just that have rays and etc.)
local ray = Ray.new(origin, (lookPos - origin).Unit * 100)
local part, pos = workspace:FindPartOnRay(ray, player.Character, false, true)
rs.Remotes.Events.Shoot:FireClient(player)
if part then
local humanoid = part.Parent:FindFirstChild("Humanoid") or part.Parent.Parent:FindFirstChild("Humanoid")
if humanoid then
if part.Name == "Head" then
humanoid:TakeDamage(headshot)
elseif part.Name == "Torso" then
humanoid:TakeDamage(damage)
else
humanoid:TakeDamage(damageSmall)
end
end
if part.Material == Enum.Material.SmoothPlastic then
if part.Name == "Glass" then
local BreakingPoint = part:FindFirstChild("BreakingPoint")
if BreakingPoint and BreakingPoint:IsA("Attachment") then
BreakingPoint.WorldPosition = part.Position
BreakingPoint.Position = Vector3.new(0, BreakingPoint.Position.Y, BreakingPoint.Position.Z)
partFracture.FracturePart(part)
end
end
end
end
local newRay = Ray.new(pos, (ray.Direction - hit2).Unit * 300)
local newPart, newPos = workspace:FindPartOnRay(newRay, player.Character, false, true)
local dis = math.round(distance); print(dis)
if newPart then
if dis == 1 or dis == 0 and part.Material == Enum.Material.Wood then
local humanoid = newPart.Parent:FindFirstChild("Humanoid") or newPart.Parent.Parent:FindFirstChild("Humanoid")
if humanoid then
if newPart.Name == "Head" then
humanoid:TakeDamage(headshot)
elseif newPart.Name == "Torso" then
humanoid:TakeDamage(damage)
else
humanoid:TakeDamage(damageSmall)
end
end
else
return
end
end
If someone can help, it would be really appreciated! Thanks.