Weapon Pickup Semi-Working?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By PrabhjotSodhi

Hello Everyone
I’m currently working on a Weapon Pickup/Drop System. I had a few questions on how should I go on about doing this. I have these different types of weapons(pistol, shotgun, rifle, etc) that I’ve placed in the scene and want to pick them up by pressing the interact key. So far I have a basic gun in the game that I can interact with. How should I go about having different types of weapons and how would I reference them in my character for the logic. So far this is the script for the character and weapon interaction

extends Camera

# Global Variables
onready var InteractCast = $InteractCast
onready var WeaponCast = $WeaponCast
onready var Muzzle = $Hand/Weapon/GunModel/Muzzle
onready var Hand = $Hand

# Local Variables
var WeaponEquipped = false
var Weapon

func _ready():
	pass

func _physics_process(delta):
	if Input.is_action_just_pressed("Interact"):
		if InteractCast.is_colliding():
			var target = InteractCast.get_collider()
			if target.is_in_group("Weapons"):
				Weapon = target
				print("InteractRaycast Hit Weapon")
				target.get_parent().remove_child(Weapon)
				target.add_child(Weapon)
				WeaponEquipped = true
			else:
				print("InteractRaycast Collided With Something")
		else:
			print("InteractRaycast Did Not Collide With Anything")
	if Input.is_action_just_pressed("Drop"):
		if WeaponEquipped:
			Hand.remove_child("Weapon")
			Weapon.set_parent(get_node("/root"))
			WeaponEquipped = false
			print(WeaponEquipped)
		else:
			print("Cant drop Weapon not Equipped!")
	
	if Input.is_action_just_pressed("FireWeapon"):
		if WeaponEquipped:
			if WeaponCast.is_colliding():
				var bullet = get_world().direct_space_state
				var collision = bullet.intersect_ray(Muzzle.transform.origin, WeaponCast.get_collision_point())
				if collision:
					var target = collision.collider
					print(target)
					if target.is_in_group("Enemies"):
						print("Weapon Hit Enemy")
				else:
					print("Weapon Hit Nothing")