So, I’ve been working on this gun system. I just want to ask what is best way to make a bullet hole attach or stick to an obstacle/wall.
game.ReplicatedStorage.LoadProjectile.OnClientEvent:Connect(function(Position1, tool, dist, startpoint, hit)
local dist = (startpoint.Position - Position1).magnitude
local part = Instance.new("Part", workspace.Debris)
local muzzle = startpoint.MuzzleEffect:Clone()
local sound = tool.Handle.Fire:Clone()
muzzle.Parent = startpoint
muzzle.Enabled = true
sound:Play()
tool.Handle.Fire:Play()
part.Size = Vector3.new(0.2, 0.2, dist)
part.Material = Enum.Material.Neon
part.Transparency = 0.6
part.BrickColor = BrickColor.new("New Yeller")
part.Anchored = true
part.CanCollide = false
part.CFrame = CFrame.new(startpoint.Position, Position1) * CFrame.new(0, 0, -dist/2)
game.Debris:AddItem(part, 0.01)
game.Debris:AddItem(muzzle, 0.1)
local hole = game.ReplicatedStorage.Hole:Clone()
hole.Parent = workspace.Debris
hole.Position = Position1
--hole.CFrame = CFrame.new(hole.Position, hole.Position+startpoint.Position, hole.Position)
hole.ParticleEmitter.Acceleration = Vector3.new(math.random(-3, 3), -10, math.random(-3, 3))
local random = math.random(1, 3)
if random == 1 then
hole.Ricochet1:Play()
elseif random == 2 then
hole.Ricochet2:Play()
elseif random == 3 then
hole.Ricochet3:Play()
end
game.Debris:AddItem(hole.ParticleEmitter, 0.8)
game.Debris:AddItem(hole, 5)
end)
Position1 = The position where the raycast hits
Tool = self-explanatory
dist = Distance between the
startpoint = The starting position of the raycast
hit = A bool value, not related to the issue