How to move slider to "value" with a button?

So I have a widget.newSlider which I am using to adjust the volume of my music.  I currently have it working.  I also have been able to use a button to mute or unmute the audio.  The problem is that I would like that the slider to move to 0 when muted, and move back when unmuted.  Currently i just get errors such as 

attempt to index upvalue 'slider' (a nil value) --This ends up pointing to this line slider.value = 0

I have tried using the following with no luck:

slider.value = 0 slider:setValue(0)

This is the whole code for my muteUnmute function (again the only thing not working is setting the slider value):

local function muteUnmute() --Currently muted, unmuteing if audioOn == false then audioOn = true if volume == 0 then volume = .1 end audio.setVolume( volume, { channel=1 } ) slider.value = volume\*100 --Currently ummuted, muteing elseif audioOn == true then audioOn = false audio.setVolume( 0, { channel=1 } ) slider.value = 0 end print("Audio on: ", audioOn) end

I think this is demonstrated in the widget demo that comes with Corona.

Also, that error message means ‘slider’ is nil.  So your scope is wrong.  Fix that and use setValue() and you should be fine.

thanks… i just had an extra local in one of my functions causing it to not be seen. 

I think this is demonstrated in the widget demo that comes with Corona.

Also, that error message means ‘slider’ is nil.  So your scope is wrong.  Fix that and use setValue() and you should be fine.

thanks… i just had an extra local in one of my functions causing it to not be seen.