--[[
	
	VERSION: v0.0.2
	
	----------[ UPDATES ]----------------------------------------------------
	
	Pre-Release: -Added a copyright
	             -fixed the issue where you couldn't run when you selected the tool
	             -Added an ADS key and allowed ADS to either be toggle or hold
	             -Made the Ammo values external so they can be changed by outside scripts
	
	v0.0.2: -Created new arms for the gun
	        -Fixed an issue where the arms would glitch if PlayerAnimations was set to false and the gun was fired
	        -Updated credit security
	        -Put the Arm cframes in the SETTINGS
	        -Made the stance changing animations slightly smoother
	        -Added bullet drop
	        -Fixed some bullet hit handling code
	        -Made the torso being able to rotate while sitting down a setting
	        -Added bullet settings
	        -Added shockwave settings
	        -Added an Explosive guntype
	        -Added a version label in the Gui
	
	-------------------------------------------------------------------------
	
	Hello there!
	
	Glad to know you're using my one and only Gun Kit!
	
	Even though this kit has many features and is rather advanced, it's pretty easy to use
	
	There are 4 things that this gun needs in order to function:
		One brick called "AimPart"
		At least one brick called "Mag"
		One brick called "Handle"
		One brick called "Main"
		
	The AimPart is what the gun will use to aim down the sights. When you aim down your sights, this brick will be in the center
	of the player's head. It basically allows the gun to have any type of sight, which can be placed anywhere on the gun. As long as
	the AimPart is aligned with the sight, the gun will aim down the sights properly.
	(NOTE: Make sure the AimPart is behind the Sight and the FRONT of the AimPart is facing the Sight)
	
	The Mag is what the gun will move around when you reload the gun. If the mag is made up of more than one brick, make sure those
	bricks are also called "Mag" so that the gun will move them around. If you set ReloadAnimation to false in the SETTINGS, you don't
	need any bricks called "Mag". But if ReloadAnimation is set to true, the gun needs at least one brick called "Mag" or it will break
	
	The Handle is obviously the most important part of the Gun. Without it, the tool itself wouldn't work. It's that simple
	(NOTE: If you want a sound to play when you fire, name it "FireSound" and place it in the Handle. If you want a sound to play when
	you reload, name it "ReloadSound" and place it in the Handle)
	
	The Main is the brick where the bullets will originate from. It's also the brick where the flash effects are kept.
	(NOTE: If you want a flash billboardgui to appear when you fire, name it "FlashGui" and place it in the Main. If you want a light
	to flash when you fire, name it "FlashFX" and place it in the Main)
	
	----------[ INSTRUCTIONS ]-----------------------------------------------
	
	HOW TO USE THIS KIT:
		1) If the gun already has a Handle, make sure it is facing forward. If the gun doesn't have a Handle, create one and place
		   it wherever you like, and make sure it is facing forward
		
		2) If the gun already has a brick called "AimPart", move it to where you would like, and make sure it is facing the sight.
		   If the gun doesn't have a brick called "AimPart", create one and move it where you would like it to be, and make sure
		   it is facing the sight
		
		3) If the gun already has a brick called "Main", move it to the very front of the gun. If the gun doesn't have a brick
		   called "Main", create one and move it to the very front of the gun
		
		4) If ReloadAnimation is set to true in the SETTINGS, make sure the gun has at least one brick called "Mag". If
		   ReloadAnimation is set to false, the gun doesn't need any bricks called "Mag".
		
		5) Open the SETTINGS and edit them however you like
		
	That's it! Only 5 steps! It's not that complicated, just follow the Directions and it should work fine. If you have any questions /
	comments / concerns, message me.
	
	     ______   ______           __          ______           _                ______
	    / _/ _/  /_  __/_  _______/ /_  ____  / ____/_  _______(_)___  ____     /  /  /
	   / // /     / / / / / / ___/ __ \/ __ \/ /_  / / / / ___/ / __ \/ __ \    / // / 
	  / // /     / / / /_/ / /  / /_/ / /_/ / __/ / /_/ (__  ) / /_/ / / / /   / // /  
	 / // /     /_/  \__,_/_/  /_.___/\____/_/    \__,_/____/_/\____/_/ /_/  _/ // /   
	/__/__/                                                                 /__/__/    
	
--]]

wait(math.random(0, 200) / 200) --This is to prevent more than one Ignore_Model from being created

if _G.Ignore_Code then --If the Ignore_Code already exists, then the script creates the Ignore_Model
	--[[
		The purpose of this is so that every gun in a game that uses this gun kit will share one Ignore_Model. That way,
		bullet trails, bullet holes, and other fake arms will be ignored by the gun which makes the bullets more likely to
		hit a character part
	--]]
	if (not game.Workspace:FindFirstChild("Ignore_Model_".._G.Ignore_Code)) then
		local Ignore_Model = Instance.new("Model")
		Ignore_Model.Name = "Ignore_Model_".._G.Ignore_Code
		Ignore_Model.Parent = game.Workspace
	
		spawn(function()
			while true do
				Ignore_Model.Parent = game.Workspace
				wait(1 / 20)
			end
		end)
	end
	
	script.Parent:WaitForChild("Gun_Main"):WaitForChild("Ignore_Code").Value = _G.Ignore_Code
else
	--[[
		If there isn't already an Ignore_Code, then this creates one. The purpose of it being random is so that if there is
		an Ignore_Model for something else in the game, the script won't end up placing the ignored objects in that Ignore_Model
	--]]
	_G.Ignore_Code = math.random(1, 1e4)
	
	if (not game.Workspace:FindFirstChild("Ignore_Model_".._G.Ignore_Code)) then
		local Ignore_Model = Instance.new("Model")
		Ignore_Model.Name = "Ignore_Model_".._G.Ignore_Code
		Ignore_Model.Parent = game.Workspace
	
		spawn(function()
			while true do
				Ignore_Model.Parent = game.Workspace
				wait(1 / 20)
			end
		end)
	end
	
	script.Parent:WaitForChild("Gun_Main"):WaitForChild("Ignore_Code").Value = _G.Ignore_Code
end