Maybe the function is not very friendly to calculate the spaces between objects that are not the same size; both the left and right buttons are changed in position in the updateHotbar() function. Yesterday I tried making the separation separately, and it only makes things complicated. I will make the arrows the same size as the other buttons.
Are you sure that the problem isn’t in these arrows? Run the game, check the position of the frame that holds the buttons and see if it’s closer to one of the arrows, if it is then you found the problem, if not, I can’t really find any issues with the code.