Script can't be added to a component

So I try to drag a script from the assets panel on to an object in the Hierarchy panel, and instead of being added to the object as a component it says: “Can’t add component ‘insert script name’ because it doesn’t exist. Check to see if the file name and class name match.” However, the class name and the script’s name both are exactly the same. Can anyone tell me what’s going on?

Try to remove special characters and spaces from your file and class name, e.g. “Some Script$” should be “SomeScript”.
Also make sure the Script actually compiled without an error.

Many times it is seen that there are some errors in script.PLease rectify if any , braces or any.
Please save the script first and then add to component.This should solve the issue.Else please post your script.