Bullet Hole Marking Problem

Hey there, I made gun that is marking where the bullet was hitted by wall etc. it works well but for one small problem, when I shoot twice on same direction the 2th raycast will detect bullet so it is going to make hole mark in air and I don’t want that here is my script:

				if not hit.Parent:FindFirstChild("Humanoid") and hit.Name ~= "Handle" and hit.Name ~= "Bullet" then
					local bulletHole = Instance.new("Part",workspace)
					bulletHole.Name = "Hole"
					bulletHole.CFrame = CFrame.new(result.Position,result.Position + result.Normal)
					bulletHole.Size = Vector3.new(0.35, 0.35, 0.05)
					bulletHole.Transparency = 1
					bulletHole.CanCollide = false
					local image = Instance.new("Decal",bulletHole)
					image.Texture = "http://www.roblox.com/asset/?id=2078626"
					image.Face = "Front"

If anybody know how could I pretend happening please comment down below!

1 Like

Maybe make it also check if the name of hit is not Hole?

if not hit.Parent:FindFirstChild("Humanoid") and hit.Name ~= "Handle" and hit.Name ~= "Bullet" and hit.Name ~= "Hole" then

This would not work because the old raycast still detected the bullet and thats how im calculating the position of hole marking

Hmm. First off, when making projectiles it’s commonly known that Raycasting is more reliable then the Touched event. While it does seem like your code utilizes Raycasting, it only seems to do so to position the bullet hole. Because your code uses the touched event the only advice I can give you is to use the new BasePart.CanTouch property to disable the bullets being able to fire this event.

That feature is not out yet however, so if you want to make it work right now then you can do some Raycasting utilizing RaycastParams. Raycasting parameters can help you filter out parts you don’t want to hit. Basically you raycast and update the bullets position each loop iteration and if the raycast returns a result then you break the loop, destroy the bullet, and use the result to position the bullet hole.

1 Like

Make a table named “IgnoreList”, make a for loop that detects the entire workspace for transparent parts then add them in to the IgnoreList. When a bullet hole is formed/spawned/cloned, you can go ahead and insert the bullet hole into the IgnoreList, make sure you set IgnoreList to blacklist. You can also add a folder in the workspace named “Debris”, this way every bullet hole/debris will be stored in the folder can be ignored.

local IgnoreList = {}
local TransparentParts = {}

for _,v in pairs(TransparentParts) do

for _,v in pairs(workspace.Debris:GetChildren())do

for _,part in pairs(workspace:GetDescendants())do
	if part:IsA("BasePart") then
		if part.Parent == workspace.Debris then
		if part.Transparency > 0.95 then
1 Like