Questions about making combat/weapon systems

Hello, I have a few questions about making a combat/weapon system.
Before we continue, sorry if this don’t make any sense, I am bad at explaining :sweat_smile:

(For these questions, I am trying to avoid using Tools)

  • First Question;
    How can I change the state of the weapon itself? So if a player previously had a melee weapon then unlocked a pistol or something, how can I make my script detect weather they changed weapons and change the melee script to the gun script?

  • Second and hopefully question;
    This also relates to the first question but when a player switches to a new weapon, how can I change the weapon script to the one they have? For example I equip a sword, then later in the match I equip a gun, how could I make the weapon change to the correct script, so a gun doesn’t function like a sword would.

Any feedback will be appreciated!