I tried making this automatic but it won’t work. Can someone help me?
m.Button1Down:connect(function()
if equip_value == true or reloading or toggle == false or chamber.IsPlaying then return end
if ammo <= 0 or chambered == false then t.Parent.Events.Empty:FireServer() return end
if not running then
running = true;
self = t.Parent.Parent;
local ray = Ray.new((muzzle.CFrame.p + Vector3.new(0, 0, 0)), ((m.Hit.p - muzzle.CFrame.p).unit * 100))
local hit, position = workspace:FindPartOnRay(ray, self);
local spread_amount = math.random(-1.25,1.25)
position = Vector3.new(position.X + (spread_amount * spread_amount * math.random()),position.Y + (spread_amount * spread_amount * math.random()),position.Z + (spread_amount * spread_amount * math.random()))
pcall(function()
if hit.Parent.Humanoid then
t.Parent.Events.Damage:FireServer(hit, damage);
end
end);
shoot:Play()
t.Parent.Events.Laser:InvokeServer(self, position, muzzle);
t.Parent.Events.Shoot:FireServer()
ammo-=1
if ammo == 0 and reserve == 0 then
game.Players.LocalPlayer.PlayerGui.ammoGui.Chamber.Text = "NOT CHAMBERED"
end
game.Players.LocalPlayer.PlayerGui.ammoGui.Ammo.Text = ammo
t.Parent.Events.Bullet:FireServer()
ShootRecoil()
print(ammo)
wait(cool - .1);
running = false;
end;
end)
end)```