How do I use the layer parameter in a function?

I am trying to create a function for parallax, where one of the parameter is layer. But I can not get the function to recognize my layer parameter as a layer.