When holding E and I press another key that has a bind for it, the barrage doesn't stop

When I hold E, a barrage animation plays, while damaging anyone that gets hit. When I press R or F while holding E (i have a bind for that in the script) and release E, the barrage animation continues to play, even though I release E. But if I press a key that doesn’t have a bind, the barrage animation continues to play and when I release E, the barrage animation stops. I’ve done some testing, and it’s not on the server. The remote event just doesn’t send at all. Here’s the local script that handles all of the keybinds:

Script
local UIS = game:GetService("UserInputService")
local RS =  game:GetService("ReplicatedStorage")

local summon  = RS:WaitForChild("Summon")
local action  = RS:WaitForChild("Action")
local barrage = RS:WaitForChild("Barrage")

local player = game.Players.LocalPlayer

--// Summon
local db = false
local active = false
local cd = 2
--// End

--// Barrage
local barraging = false
local barrage_db = false
local barrage_cd = 1
--// End

--// Punch Combat
--///Punch
local ct = 0
local prev = 0
local curr = 0
local m1_cd = 0.5
local m1_db = false
--/// Heavy Punch
local m2_db = false
local m2_cd = 3
--// End



UIS.InputBegan:Connect(function(input, typing)
	local stand = player.Character:FindFirstChildWhichIsA("Model")
	if typing then return end
	if input.KeyCode == Enum.KeyCode.Q then
		if db == false and active == false then
			active = true
			db = true
			
			summon:FireServer(active)
			task.wait(cd)
			db = false
		elseif db == false and active == true then
			active = false
			db = true
			
			summon:FireServer(active)
			task.wait(cd)
			db = false
		end
	else
		if active then
			if input.KeyCode == Enum.KeyCode.E then
				if barrage_db == false then
					barraging = true
					barrage:FireServer(stand, true)
					task.wait(barrage_cd)
					barrage_db = false
					if barrage_db == false then
						barrage_db = true
						task.wait(barrage_cd)
						barrage_db = false
					end
				end
			elseif input.KeyCode == Enum.KeyCode.R then
				if m2_db == false then
					m2_db = true
					action:FireServer("HeavyPunch", stand)
					task.wait(m2_cd)
					m2_db = false
				end
			else
				if barraging == false then
					if input.UserInputType == Enum.UserInputType.MouseButton1 then
						if m1_db == false then
							m1_db = true
							curr = tick()
							if curr - prev < 1 then
								ct += 1
								if ct > 4 then
									ct = 1
								end
							else
								ct = 1
							end
							action:FireServer("Punch", stand, ct)
							prev = curr
							task.wait(m1_cd)
							m1_db = false
						end
					elseif input.KeyCode == Enum.KeyCode.F then
						action:FireServer("TimeStop", stand, 8)
					end
				end
			end
		end
	end
end)

UIS.InputEnded:Connect(function(input, typing)
	if typing then return end
	if active then
		if input.KeyCode == Enum.KeyCode.E then
			if barraging == true and barrage_db == false then
				barraging = false
				barrage_db = true
				barrage:FireServer(player.Character:FindFirstChildWhichIsA("Model"), false)
				task.wait(barrage_cd)
				barrage_db = true
			end
		end
	end
end)

game.ReplicatedFirst.GetStand.OnClientInvoke = function()
	return player:FindFirstChildWhichIsA("Model")
end

Is the :InputEnded part of the script running at all? Or is it just the animation that isn’t stopping?

The remote event that fires to the server, which stops the animation isn’t firing. I’ve done some more testing, and in the following line, barraging remains false and barrage_db remains true, which is the opposite of what it should be.

if barraging == true and barrage_db == false then

Line 109.

Really random, try removing the if typing return end bit, I’ve seen the gameProcess part of InputEnded screw up loads in my own experimentation.

It somewhat fixed it. Both barraging and barrage_db are true, and I can stop the animation by pressing E and releasing it again, which I couldn’t do before. But I’d prefer to keep the typing if statement, because I don’t want any keys to register while typing.

If it’s not spewing up any errors it should work. All your variables are defined correctly.

I’ll send a video of what’s happening.

1 Like

The first video is where I barrage once, and release. I can’t do it again.

The second video is where I barrage, press R, then release. I spam E, and it won’t fire.