So, I have an automatic gun, and every time it fires a bullet it sends a RemoteEvent to fire the bullet. Thing is, it fires pretty slow, and I can fire faster on semi. How would I lessen the delay?

I have it set to 0 because I want it to be as fast as possible, but it doesn't seem to care.

--Code fragment.
mouse.Button1Down:Connect(function()
    	if automaticFire and cooldown == false then
    		mouseDown = true
    		while mouseDown and automaticFire do
				if scriptLoaded > 0 and lowered == false then
					if fireRate > 0 then
						cooldown = true		
					end			
					scriptLoaded = scriptLoaded - 1
					player.PlayerGui.ammoDisplay.Frame.ammo.Text = scriptLoaded .. "/" .. scriptUnloaded
					fireBullet()
					cooldown = false
				else
					mouseDown = false
					local emptyChamber = Instance.new("Sound")
					emptyChamber.Parent = tool.firePart
					emptyChamber.SoundId = "http://www.roblox.com/asset/?id=" .. gunEmpty
					emptyChamber:Play()
					wait(1)
					emptyChamber:Destroy()
				end
   	    	end
end

5 comments

0

You cannot. The signals on your computer and ROBLOX's servers is trying to travel as fast as they can. Unless you have magic, you cannot speed this up.

0

Alright. Any ideas how other gun scripts make them fire so fast then?

0

They could fire the remote event once and have the script fire 5 times every remote event fire

0

or just don use a remove event

0

I mean, what else am I supposed to do? It's FilteringEnabled, and it's firing from a LocalScript. It won't do anything without a RemoteEvent.