Hi!
You could have Mentioned that Maya gives you the Error:
# Error: TypeError: file <maya console> line 24: Object ['l_shoulder']_ik is invalid
That usually helps finding problems.^^
What is happening here is that the ls() function always gives you a list, so when you use the line:
tempjointList.append(jointRoot)
You are appending a list within a list. Instead of appending the string in the list to the list.
You can either use:
tempjointList.append(jointRoot[0])
if you want to have the selection limited to the first selected element. which would make sense with the rest of the code
or you can use:
tempjointList = tempjointList + rootJoint
This merges the lists, which gives the possibility of multiple selections. But since you are directly relying on list index later on thats probably not what you want here.
Also, you'll need to use rootJoint[0] as well for your if statements, otherwise they will never activate.
I hope this helps!