--


tool.Equipped:connect(function()
	equipped = true
	trail.Enabled = false
	cananimate = true
	canattack = false
	handle.Transparency = 1
	owner = game:GetService("Players"):GetPlayerFromCharacter(tool.Parent)
	character = owner.Character
	local rightarm = Instance.new("Weld", character.Torso)
	rightarm.Part0 = character.Torso
	rightarm.Part1 = character["Right Arm"]
	rightarm.C0 = CFrame.new(1.5,0,0)
	rightarm.Name = "RightArmWeldbat"
	local leftarm = Instance.new("Weld", character.Torso)
	leftarm.Part0 = character.Torso
	leftarm.Part1 = character["Left Arm"]
	leftarm.C0 = CFrame.new(-1.5,0,0)
	leftarm.Name = "LeftArmWeldbat"
	local head = Instance.new("Weld", character.Torso)
	head.Part0 = character.Torso
	head.Part1 = character.Head
	head.C0 = CFrame.new(0,1.5,0)
	head.Name = "HeadWeldbat"
	local humanoidrootpart = Instance.new("Weld", character.HumanoidRootPart)
	humanoidrootpart.Part0 = character.HumanoidRootPart
	humanoidrootpart.Part1 = character.Torso
	humanoidrootpart.Name = "HumanoidRootPartWeldbat"
	for i = 0,1 , 0.05 do
		humanoidrootpart.C0 = humanoidrootpart.C0:lerp(CFrame.fromEulerAnglesXYZ(0,math.rad(25),0),i)
		leftarm.C0 = leftarm.C0:lerp(CFrame.new(-1.5,0.5,0) * CFrame.fromEulerAnglesXYZ(math.pi+math.rad(10),math.rad(75),math.rad(-10)) * CFrame.new(0,-0.5,0),i)
		rightarm.C0 = rightarm.C0:lerp(CFrame.new(1.5,0.5,0) * CFrame.fromEulerAnglesXYZ(0,0,math.rad(10)) * CFrame.new(0,-0.5,0),i)
		runservice.Stepped:wait()
	end
	local grip = character["Right Arm"]:WaitForChild("RightGrip")
	grip.Part1 = nil
	local weldd = Instance.new("Weld", handle)
	weldd.Part0 = character["Left Arm"]
	weldd.Part1 = handle
	weldd.Name = "AIDS"
	weldd.C0 = CFrame.new(0, 0, -1.70000005, 0, 0, 1, 1, 0, 0, 0, 1, 0) * CFrame.fromEulerAnglesXYZ((math.pi/2),math.rad(15),0) * CFrame.new(-0.7,0,-0.1)
	cananimate = true
	if character:findFirstChild("BatBack") then
		character:findFirstChild("BatBack").Transparency = 1
	end
	handle.Transparency = 0
	equipsound:Play()
	local WHEN = 0
	coroutine.wrap(function()
		while runservice.Stepped:wait() and equipped do
			if cananimate then
				if WHEN < 40 then
					WHEN = WHEN + 1
				elseif WHEN == 40 then
					WHEN = 41
					grip.Part1 = handle
					canattack = true
					weldd:destroy()
				end
				tool.Grip = tool.Grip:lerp(CFrame.new(0, 0, -1.70000005, 0, 0, 1, 1, 0, 0, 0, 1, 0),0.1)
				head.C0 = head.C0:lerp(CFrame.new(0,1.5,0),0.1)
				humanoidrootpart.C0 = humanoidrootpart.C0:lerp(CFrame.new(),0.1)
				leftarm.C0 = leftarm.C0:lerp(CFrame.new(-1.4,0.5,0) * CFrame.fromEulerAnglesXYZ((math.pi/2)-math.rad(50)+math.sin(tick())/15,0,math.rad(50)) * CFrame.new(0,-0.8,0),0.1)
				rightarm.C0 = rightarm.C0:lerp(CFrame.new(1.5,0.5,0) * CFrame.fromEulerAnglesXYZ((math.pi/2)-math.rad(35)+math.sin(tick())/15,math.rad(20),math.rad(-40)) * CFrame.new(0,-0.8,0),0.1)
			end
		end
	end)()
end)
tool.Unequipped:connect(function()
	equipped = false
	mouseclick = false
	cananimate = false
	if character.Torso:findFirstChild("LeftArmWeldbat") then
		character.Torso:findFirstChild("LeftArmWeldbat"):destroy()
	end
	if character.Torso:findFirstChild("RightArmWeldbat") then
		character.Torso:findFirstChild("RightArmWeldbat"):destroy()
	end
	if character.Torso:findFirstChild("HeadWeldbat") then
		character.Torso:findFirstChild("HeadWeldbat"):destroy()
	end
	if character:findFirstChild("HumanoidRootPart") then
		if character.HumanoidRootPart:findFirstChild("HumanoidRootPartWeldbat") then
			character.HumanoidRootPart:findFirstChild("HumanoidRootPartWeldbat"):destroy()
		end
	end
	if not character:findFirstChild("BatBack") then
		local clone = handle:Clone()
		clone:BreakJoints()
		for i,v in pairs(clone:GetDescendants()) do
			if v.ClassName ~= "SpecialMesh" and v.ClassName ~= "TouchTransmitter" then
				v:destroy()
			end
		end
		local weld = Instance.new("Weld", clone)
		weld.Part0 = character.Torso
		weld.Part1 = clone
		weld.C0 = CFrame.new(0,0,0.55)
		weld.C0 = weld.C0 * CFrame.fromEulerAnglesXYZ(0,math.pi/2,math.pi/2)
		weld.C0 = weld.C0 * CFrame.fromEulerAnglesXYZ(math.pi,math.rad(60)+math.pi,0)
		clone.Parent = character
		clone.Name = "BatBack"
	else
		character:findFirstChild("BatBack").Transparency = 0
	end
	handle.Transparency = 1
	character.BatBack:findFirstChildOfClass("SpecialMesh").TextureId = handle:findFirstChildOfClass("SpecialMesh").TextureId
end)