Stuck with scaling an object

I’ve been trying to scale an object using its x,y,z axis using a slider. However, I have a problem trying to use 3 different sliders for each axis (x for length, y for width, and z for height). The problem is that only one slider works (which the only thing that scales is the height) in the code that I’ve done even though I’ve declared 3 sliders to perform a transform function for each axis. Can someone please tell me what’s wrong and how to debug something like this? I’ve very new in unity. Thanks :slight_smile:

Here’s the code that I used on my sliders

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class ScaleSlider : MonoBehaviour {

	public Slider sliderLength;
	public Slider sliderWidth;
	public Slider sliderHeight;

	// Use this for initialization
	void Start () {
		sliderLength.value = 1;
		sliderWidth.value = 1;
		sliderHeight.value = 1;

	}

	// Update is called once per frame
	void Update () {
		transform.localScale = new Vector3 (sliderLength.value*1f, 1, 1);
		transform.localScale = new Vector3 (1, sliderWidth.value*1f, 1);
		transform.localScale = new Vector3 (1, 1, sliderHeight.value*1f);
	}
}

private float X = 0f;
private float Y = 0f;
private float Z = 0f;

void Update()
{
X = sliderLength.value;
Y = sliderWidth.value;
Z = sliderHeight.value;

transform.localScale = new Vector3(X, Y, Z);
}