Thanks to @RokCoder for helping me with this code on the forums! @bestvitalic2 also fixed it, but by the time they did, rokcoder had already fixed it.