Remoteevents stacking?

  1. What do you want to achieve?
    I am trying to make a gatling/minigun thats shoots really fast

  2. What is the issue?
    When the gun is unequipped and re-equipped, it shoots twice or more

  3. What solutions have you tried so far?
    Sadly as far as i have looked, nobody is talking about this, yet i cant seem to fix this, any kind of help would be appreciated

Tool.Equipped:Connect(function()
	toolon = true
	Humanoid.WalkSpeed = 9
	idle:Play()
	mouse.Button1Down:Connect(function()
		if toolon == true then
			isfiring = true
			idle:Stop()
			firing:Play()	
			spawn(function()
				while isfiring == true do
					wait(0.5)
					startfiring:FireServer(mouse.hit.p, gatling, value)

				end
			end)
				end	
			end)	
			
		end)	

You are using a wait of 0.5, every time you pass 0.5 the bullet will be thrown, try to remove it or reduce it to a minimum amount, like, 0.05.

You’re creating a new connection each time you equip the tool, and not disconnecting it when the tool is unequipped. That’s why it stacks when you re-equip the tool. Try disconnecting it when unequipping, or use a variable to control when you can or cannot fire.


local toolon = false

Tool.Equipped:Connect(
    function()
        toolon = true

        Humanoid.WalkSpeed = 9
        idle:Play()
    end)

Tool.Unequipped:Connect(
    function()
        toolon = false
    end)

mouse.Button1Down:Connect(
    function()
        if toolon == true then
            isfiring = true
            idle:Stop()
            firing:Play()
            spawn(
                function()
                    while isfiring == true do
                        wait(0.5)
                        startfiring:FireServer(mouse.hit.p, gatling, value)
                    end
                end)
        end
    end)


local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()

local Tool = script.Parent

local Connection

Tool.Equipped:Connect(function()
	Connection = Mouse.Button1Down:Connect(function()
		--Fire server here.
	end)
end)

Tool.Unequipped:Connect(function()
	if Connection then
		if Connection.Connected then
			Connection:Disconnect()
			Connection = nil
		end
	end
end)