I made a functioning Double Barrel gun. But there’s a problem, whenever I reloaded the gun. This happened to me :
(Ignore the Background Music)
So, the shells multiplying every reload. I have a code about that clones the shell and reject as the handler racks. I’ll also show you the image of my Double Barrel explorer if it seems to be the problem.
The code below me is related to reloading function with some shell ejecting. There’s nothing related about this besides the other line neither a local script.
function reload(player)
if not cooldown[player] and gun.Parent == player.Character and ammo.Value < confs.Ammo then
cooldown[player] = true
if confs.ReloadWhileInBackpack then
accept_reload = true
end
remote:FireClient(player, "Reload")
remote.OnServerEvent:Connect(function(player, status)
if status == "Racks" then
handle.ReloadSound.Racks:Play()
elseif status == "InsertAmmo" then
handle.ReloadSound.InsertBullet:Play()
elseif status == "ShellEject" then
if confs.ShellEjectPart then
for i, bullet in pairs(bullets:GetChildren()) do
local clonedBullet = bullet:Clone()
clonedBullet.Parent = workspace:WaitForChild("BulletWaste")
clonedBullet.CFrame = bullet.CFrame
clonedBullet.CanCollide = true
clonedBullet:SetNetworkOwner(player)
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyVelocity.Velocity = (clonedBullet.CFrame.RightVector * -15)
bodyVelocity.Parent = clonedBullet
game:GetService("Debris"):AddItem(bodyVelocity, 0.1)
game:GetService("Debris"):AddItem(clonedBullet, 2)
end
end
handle.ReloadSound.AmmoShell:Play()
end
end)
task.wait(confs.ReloadTime)
if accept_reload then
ammo.Value = confs.MaxAmmo
end
cooldown[player] = false
end
end
I’m not going to reply at this early time but I’ll reply back around 2 PM (UTC +8)