it's always best to assign an action a name:
_actionName = player addAction ["text","scriptname.sqs"]
Because then, when the action needs to be removed things become much simpler as you can use the action name rather than an index number which can be very unreliable.
player removeAction _actionName