-------------------------------


local tool = script.Parent
local player = game.Players.LocalPlayer
while player.Character == nil do wait() end
local char = player.Character
while char:FindFirstChild("Humanoid") == nil do wait() end
local hum = char:FindFirstChild("Humanoid")
while char:FindFirstChild("Head") == nil do wait() end
local head = char:FindFirstChild("Head")
local tauntanim = hum:LoadAnimation(script.hold)


local w = nil
function Click()
	local player = game.Players.LocalPlayer
	local char = player.Character
	
		hummer = char.Humanoid
			
		if char ~= nil then
			local torso = char:FindFirstChild("Torso")
			local arm = char:FindFirstChild("Right Arm")
			if torso ~= nil and arm ~= nil then
				local shoulder = torso:FindFirstChild("Right Shoulder")
				if shoulder ~= nil then
				
				
			end
		end
	end
end
function Unclick()
	if c ~= nil and t ~= nil then
		if w ~= nil then
			w:Destroy()
			s.Parent = t
			s.C0 = c0
			s.C1 = c1
		end
		local ani = char:FindFirstChild("Animate")
		if ani ~= nil then
			local d = ani:clone()
			ani.Parent = nil
			wait()
			ani = d
			ani.Parent = c
		end
	end
end

local enabled = true
local charged = false
local poopdb = false
local equipped = false

local slowdown1 = nil
tool.Equipped:connect(function(mouse)
	equipped = true
	mouse.Icon = "rbxasset://textures\\GunCursor.png"
	mouse.Button1Down:connect(function()
		if hum == nil then return end
		if hum.Health <= 0 then return end
		if mouse == nil then return end
		if enabled then
			if not charged then
				enabled = false
				Click()
				if hum:FindFirstChild("Effects") then
					slowdown1 = Instance.new("IntValue")
					slowdown1.Name = "Speed"
					slowdown1.Value = -6
					slowdown1.Parent = hum:FindFirstChild("Effects")
				end
					tauntanim:Play()
				local charge_sound = Instance.new("Sound")
				charge_sound.Name = "ChargeSound"
				charge_sound.SoundId = "rbxassetid://"
				charge_sound.Pitch = math.random(2, 5)/10
				charge_sound.Looped = false
				charge_sound.Parent = head
				charge_sound:Play()
				local nose_decal = Instance.new("Decal")
				
				nose_decal.Name = "Nose"
				nose_decal.Parent = head
				for i = 1, 1 do
					if equipped then
						wait(5)
					end
				end
				if charge_sound ~= nil then
					charge_sound.Volume = 0
					charge_sound:Stop()
					charge_sound:Destroy()
				end
				if equipped then
					Unclick()
					tool.Handle.Transparency = 0
					charged = true
				end
				if nose_decal ~= nil then
					nose_decal:Destroy()
				end
				if slowdown1 ~= nil then
					slowdown1:Destroy()
				end
				enabled = true
			elseif mouse.Hit ~= nil then
				enabled = false
				charged = false
				tool.Handle.Transparency = 0
				script.Parent.ShootProjectile:FireServer(mouse.Hit.p)
				mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
				wait(0.4)
				tool.Handle.Transparency = 0
				wait(RELOAD_TIME)
				mouse.Icon = "rbxasset://textures\\GunCursor.png"
				enabled = true
			end
		end
	end)
end)
	

tool.Unequipped:connect(function()
	equipped = false
		tauntanim:Stop()
	charged = false
	tool.Handle.Transparency = 0
	Unclick()
end)


