How would I disconnect a keybind?

So I have a weapon and I scripted it so if they are pressing “S” while swinging, they stop going back/moving back

However, right now, it does that but once the player stops swinging, they have to press S again to start moving back, rather, I want it so once they stop swinging (they can swing consecutively btw) they are able to start moving back
tes - Roblox Studio (gyazo.com)

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift and (humanoid.MoveDirection.Magnitude > 0) then
		if block == false  then -- not blocking
			if sprintdebounce == false then
				isRunning = true
				Character.Humanoid.WalkSpeed = 34
				PlayAnim:Play()
				sprintdebounce = true
				humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
					if humanoid.WalkSpeed == 0 then
						PlayAnim:Stop()
					end
				end)
			end
		end
	elseif input.KeyCode == Enum.KeyCode.S and keybindCoolDown == false then
		isPressingS = true
	end
end)


UIS.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		if block == false then -- not blocking
			if sprintdebounce == true and keybindCoolDown == false then

				if equip == true then
					--//Get Equip Speed
					local getspeed = game.ReplicatedStorage.GameEvents.GetSpeedEquip:InvokeServer()
					if getspeed then
						Character:FindFirstChildOfClass("Humanoid").WalkSpeed = getspeed
					end
				else
					Character.Humanoid.WalkSpeed = 16
				end
				isRunning = false
				PlayAnim:Stop()
				sprintdebounce = false
			end
		end
	elseif input.KeyCode == Enum.KeyCode.S and keybindCoolDown == false then
		isPressingS = false
		if Character:FindFirstChildOfClass("Humanoid").WalkSpeed  == 0 and block == false then
			--// Get equip speed
			local getspeed = game.ReplicatedStorage.GameEvents.GetSpeedEquip:InvokeServer()
			if getspeed then
				Character:FindFirstChildOfClass("Humanoid").WalkSpeed = getspeed
			end
		end
	end
end)







--//this runs when a player left clicks
local function SwingFunction()
	if swingDebounce == false then
	
		camShake:Shake(CameraShaker.Presets.SwordHit)
		
		swingDebounce = true
		script.Parent.Cursor.Value = script.Parent.Configuration.DefaultCursor.Value
		local success, speed = game.ReplicatedStorage.GameEvents.SwingEvent:InvokeServer(SwordOrder[currentSwing], isPressingS)
		currentSwing = currentSwing + 1
		
		if success == true then
			
			if isPressingS == false then
				Character:FindFirstChildOfClass("Humanoid").WalkSpeed = speed
			
			elseif isPressingS == true then
				Character:FindFirstChildOfClass("Humanoid").WalkSpeed = 0
			
			end
			
			swingDebounce = false
		
		end
	
	end

end

https://developer.roblox.com/en-us/api-reference/class/ContextActionService

Here’s a better way to put it, how would I “refresh” a keybind, like disable then enable it like it was never pressed

local ContextAction = game:GetService(‘ContextActionService’);

ContextAction:UnbindAction(string, function, boolean, KeyCode);
task.wait(1);
ContextAction:BindAction(string, function, boolean, KeyCode);

String is the name of your action (they have to be the same in both Bind and Unbind).

Function is your function you wish to bind the input to.

Boolean is for mobile touch inputs.

KeyCode is your key code lol.

Unbind is to unbind the input, and Bind is the opposite.

Also hey I use to watch your scripting tutorial videos :slight_smile:

Or if you are unfamiliar with ContextActionService, you could just assign a variable to your input function and disconnect it (but you can’t connect it again, you will have to reassign it)

local Input = UIS.InputEnded:Connect(function()

end;

Input:Disconnect();