Gantry crane systems are often used in a variety of industrial applications to move and raise enormous weights. The process of transferring loads and weights in crane systems has always occupied the interest of researchers because of its importance in maintaining the safety of workers on the one hand and preserving the load itself from damage as a result of its swing and the possibility of it colliding with surrounding objects on the other hand. This paper's primary goal is to use a PID controller to regulate the position and swing of a GCS utilizing genetic algorithms (GA) and firefly algorithms (FA). Analytical techniques are used in the mathematical model, while Simulink in MATLAB is used in the PID model. This technique gave excellent results compared to either using the genetic algorithms (GA).