Pressing keys 2 and 4 stops the character when running

IF THIS IS A ROBLOX BUG, MODS PLEASE BE MERCIFUL AS I CAN’T POST IN ENGINE BUGS.
This issue I’m encountering is super weird, and I’m starting to believe it’s a Roblox issue.

Read under. I’m severely confused.

UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if not gameProcessed then
		repeat
			local shiftHeld = UserInputService:IsKeyDown(Enum.KeyCode.LeftShift)
			game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 18
			wait()
		until not shiftHeld
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 6
	end
end)

This is a basic running script. Not that fancy, but it gets the job done. What I noticed when testing out a hotbar I’m making is that if you press the keys 2 or 4 while running, then the character stops in it’s path.

Disabling the hotbar did nothing.

GIF of the issue

Old sprinting script I used as a placeholder up until now which acted the same.
--key = string.lower(key)
--	if string.byte(key) == 48 then
--		running = true
--		local keyConnection = mouse.KeyUp:connect(function (key)
--			if string.byte(key) == 48 then
--				running = false
--			end
--		end)
--		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 18
--		repeat wait () until running == false
--		keyConnection:disconnect()
--		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 6
--	end
--end)

PS: I don’t even know anymore. This one game here doesn’t have this issue. I’m not sure if this is because they patched it or if it’s a problem with my script.

I know this may be late but are you still experiencing this issue? Because I am and I do think that this has to be an engine bug.