private void SetExperienceBar() { float xp = experience.GetExperiencePoints() - baseStats.GetPointsForCurrentLevel(); if (xp < 0) { xp = experience.GetExperiencePoints(); } float xpNeeded = baseStats.GetPointsForNextLevel() - baseStats.GetPointsForCurrentLevel(); Vector3 newScale = new Vector3(xp / xpNeeded, 1, 1); foreground.localScale = newScale; }