im getting the error Top-level statements must precede namespace and type declarations. hers my code

Your first error is that you failed to use code tags here on the forum. The top sticky post in the scripting forum explains how to use code tags. Your second error is that you seem to don’t understand one of the most fundamental C# language elements: curly braces. Do you understand why they exist and what they are doing? What do you think this line does?

public class WeaponSwap : MonoBehaviour{}

Do you note the opening and closing braces at the end? Does that make any sense to you? You define a class that is derived from MonoBehaviour, but it’s body is empty. You know the body of a class is supposed to be inside those curly braces :slight_smile: