I’ll get straight forward.
Here’s how I replicated this issue.
One person dies or gets flung out of the map and gets removed by the game.
The turret is stuck trying to find a new target, even though they are right there.
Here’s the code.
local WeaponProperties = {
['Damage'] = 20,
['FireRate'] = 0.09,
['Speed'] = 2000,
['Distance'] = 1000,
}
local A3 = nil
local A1 = nil
local bool = true
local Base = script.Parent.Base
local fol
if not workspace:FindFirstChild(script.Parent.Placer.Value..'AAViperDebris') then
local b = Instance.new("Folder")
b.Name = script.Parent.Placer.Value..'AAViperDebris'
b.Parent = workspace
fol = b
end
while wait(1) do
local b = workspace:GetDescendants()
b = workspace:GetDescendants()
for _,_Q1 in pairs(b) do
local A2 = _Q1:FindFirstChild('Humanoid')
if A2 then
if (A2.Parent['Torso'].Position - Base.Position).magnitude < WeaponProperties.Distance then
A1 = A2.Parent['Torso']
else
A1 = nil
end
end
end
while wait(WeaponProperties.FireRate) do
if A1 ~= nil then
if A1 == nil or A1.Parent == nil then
wait(4)
repeat
wait()
print('Attempting')
local b = workspace:GetDescendants()
b = workspace:GetDescendants()
for _,_Q1 in pairs(b) do
local A2 = _Q1:FindFirstChild('Humanoid')
if A2 then
if not A2:FindFirstChild('Torso') then
-- nothing
else
if (A2.Parent['Torso'].Position - Base.Position).magnitude < WeaponProperties.Distance then
A1 = A2.Parent['Torso']
else
A1 = nil
end
end
end
end
until A1 ~= nil
else
if A1.Parent['Humanoid'].Health == 0 then
else
local Person = A1.Parent['Torso']
Base.CFrame = CFrame.new(Base.Position, Person.Position)
local Decision = math.random(1,2)
local fuse = 'Arm'..Decision
local Bullet = Base[fuse].ViperBullet:Clone()
Bullet.Parent = fol
Bullet.Transparency = 0
Bullet.c:Destroy()
Bullet.Velocity = Base.CFrame.LookVector * WeaponProperties.Speed
local d = game:GetService('Debris')
d:AddItem(Bullet,5)
Bullet.Touched:connect(function(part)
if game.Players:FindFirstChild(part.Parent.Name) then
part.Parent['Humanoid']:TakeDamage(WeaponProperties.Damage)
else
if part.Parent:FindFirstChild('Humanoid') then
part.Parent['Humanoid']:TakeDamage(WeaponProperties.Damage)
end
end
if part.Name == 'ViperBullet' or part.Name == 'Arm1' or part.Name == 'Arm2' then
-- nothing
else
Bullet:Destroy()
end
end)
end
end
end
end
end
Suggestions and Solutions are greatly appreciated.
P.S: I don’t have a specific solution I was looking for, so I have to go to the devforum.
Some of the dummies die because of misfire, other than that then they are alive.