@philip1999,
Please read @mbozzi's post. You need that ampersand & in the parameter list of the function definition. Otherwise player will be passed by value: i.e. only a copy goes to your function and nothing goes back. I appreciate that this may be different from some other programming languages.