Heya, so I’ve got this problem, I’m raycasting to detect if my bullet hits anything, everything works fine except when the bullet is destroyed, there seems to be some kind of invisible bullet still being left, which will go through all walls, (with a certain speed!) and leave bullet holes there too. Here’s a snippet of my code. In conclusion: Original bullet is destroyed but there is some kind of invisible one that’ll leave bulletholes in all of the walls behind the original one.
local trajectory = coroutine.wrap(function()
while bullet do
bullet.CFrame = bullet.CFrame + bullet.CFrame.LookVector * speed
local ray = Ray.new(bullet.CFrame.p, bullet.CFrame.LookVector * speed)
local object, position,normal = game.Workspace:FindPartOnRayWithIgnoreList(ray, {plr.Characrer}, false, true)
if object and bullet then
if object.Parent:FindFirstChildWhichIsA("Humanoid") ~= nil then
local hum = object.Parent:FindFirstChildWhichIsA("Humanoid")
hum:TakeDamage(10)
bullet:Destroy()
else
local bullethole = coroutine.wrap(function(position,normal)
local bulhole = game.ReplicatedStorage.Bullethole:Clone()
bulhole.Parent = workspace
bulhole.CFrame = CFrame.new(position,position + normal)
-- bulhole.Dirt.Enabled = true
bulhole.Smoke.Enabled = true
wait(0.1)
-- bulhole.Dirt.Enabled = false
bulhole.Smoke.Enabled = false
game:GetService("Debris"):AddItem(bulhole,5)
end)
bullethole(position,normal)
bullet:Destroy()
end
end
game:GetService("RunService").Heartbeat:Wait()
end
end)
trajectory()
And yes, I’m using a deprecated function because I made this a while back, although that shouldn’t be the problem. Help would be appreciated!