Assuming that your public scrollbar object indeed has an UI.Scrollbar component attached, you should try this
public GameObject scrollbar;
//Add a reference to the scrollbar component
Scrollbar myScrollbar;
void Start() {
myScrollbar = scrollbar.GetComponent<Scrollbar>();
}
void Update () {
moveVelocity = 0f;
if (myScrollbar.value >= 0.5)
{
moveVelocity = moveSpeed;
}
if(scrollbar.value <= 0.5)
{
moveVelocity = -moveSpeed;
}
}
Don’t forget to add the reference to the UnityEngine.UI namespace at the beginning of your class so you can have access to the objects. Just go to the top of your class and add: