Some background
Adding a script tool—Help | ArcGIS for Desktop
plus others... I will let you look up the links in the same area
Setting script tool parameters—Help | ArcGIS for Desktop
Accessing parameters in a script tool—Help | ArcGIS for Desktop
etc
But in summary, when you are working within arcmap and set your environment workspace and select a layer as input to a tool, the script will work with the layer and use any selection placed upon it. If you run that same script and don't provide a full working path to the file, either by setting the environments or directly providing it. The script has no clue where the file is located.
The best way is to look at the options available to you when you specify a feature layer, a feature class etc. Some parameters have a little black drop down arrow beside a folder icon. if you select from the list provided by clicking on that arrow, you can choose from layers within arcmap. Alternately, if you click on the folder icon, you get to navigate to the file on disk.
Consider the scenario... you have a layer in arcmap with a selection... you decide to run some tool... if that tool uses the layer within arcmap, only the features selected process will be used by the tool.
But!!! Damn you say... I want to use this tool, but I don't want to undo the selection... what to do??? simply click on the folder icon, navigate to that file on disk and the process will be run on the whole file REGARDLESS of the selection in ArcMap... cool trick... or a stumbling block.
What to do? add print statements (for pure python code running) and arcpy.AddMessage statements (for toolbox reporting. Check what you have. If you think you have a file on disk, but all that is reported is the file's name without the path, then you know you have a problem.
The only way to figure out what is what... is to try it, giving the rules are easily forgotten... as for the messaging
in_fc = arcpy.GetParameterAsText(0)
msg = "Input paramater 1... { }".format(in_fc)
print(msg)
arcpy.AddMessage(msg)
You can make that print/addmessage into a little def if you want
def stuff(msg):
"""print stuff for python and/or toolbox scripts"""
print(msg)
arcpy.AddMessage(msg)
then you just call it
stuff(msg)
that is all for now