--just send ur backup tick to the function and it should work fineeeee


tool.Activated:Connect(function()
	if state == "idle" then
		state = "swinging"
		for i,v in pairs(hitpeople) do
			hitpeople[i] = nil
		end
		local backuptick = equiptick
		if (tick() - lastswingtick) > 2 then
			swinganimation = 0
		end
		if swinganimation == 0 then
			swinganimation = 1
			charhum.WalkSpeed = charhum.WalkSpeed + speedbuff
			pose("swing", 1, 0.25*animslowdownmult, backuptick)
			wait(0.2*animslowdownmult)
			trail.Enabled = true
			remote:FireClient(player, "1")
			playswingid()
			pose("swing", 2, 0.05*animslowdownmult, backuptick)
			wait(0.05*animslowdownmult)
			pose("swing", 3, 0.2*animslowdownmult, backuptick)
			wait(0.2*animslowdownmult)
			remote:FireClient(player, "2")
			trail.Enabled = false
			charhum.WalkSpeed = charhum.WalkSpeed - speedbuff
			pose("equip", 2, 0.5*animslowdownmult, backuptick)
			wait(0.3*animslowdownmult)
			if backuptick == equiptick then
				state = "idle"
			end
		elseif swinganimation == 1 then
			swinganimation = 2
			charhum.WalkSpeed = charhum.WalkSpeed + speedbuff
			pose("swing2", 1, 0.25*animslowdownmult, backuptick)
			wait(0.2*animslowdownmult)
			trail.Enabled = true
			remote:FireClient(player, "1")
			playswingid()
			pose("swing2", 2, 0.15*animslowdownmult, backuptick)
			wait(0.15*animslowdownmult)
			pose("swing2", 3, 0.1*animslowdownmult, backuptick)
			wait(0.1*animslowdownmult)
			charhum.WalkSpeed = charhum.WalkSpeed - speedbuff
			pose("swing2", 4, 0.2*animslowdownmult, backuptick)
			wait(0.2*animslowdownmult)
			remote:FireClient(player, "2")
			trail.Enabled = false
			pose("equip", 2, 0.5*animslowdownmult, backuptick)
			wait(0.3*animslowdownmult)
			if backuptick == equiptick then
				state = "idle"
			end
		elseif swinganimation == 2 then
			swinganimation = 0
			charhum.WalkSpeed = charhum.WalkSpeed + speedbuff
			pose("swing3", 1, 0.1*animslowdownmult, backuptick)
			wait(0.1*animslowdownmult)
			pose("swing3", 2, 0.35*animslowdownmult, backuptick)
			wait(0.3*animslowdownmult)
			trail.Enabled = true
			remote:FireClient(player, "1")
			playswingid()
			pose("swing3", 3, 0.1*animslowdownmult, backuptick)
			wait(0.1*animslowdownmult)
			pose("swing3", 4, 0.16*animslowdownmult, backuptick)
			wait(0.08*animslowdownmult)
			remote:FireClient(player, "2")
			trail.Enabled = false
			charhum.WalkSpeed = charhum.WalkSpeed - speedbuff
			pose("swing3", 5, 0.1*animslowdownmult, backuptick)
			wait(0.1*animslowdownmult)
			pose("equip", 2, 0.5*animslowdownmult, backuptick)
			wait(0.5*animslowdownmult)
			if backuptick == equiptick then
				state = "idle"
			end
		end
		lastswingtick = tick()
	end
end)
tool.Equipped:Connect(function()
	state = "equipping"
	validatetick = tick()
	local backuptick = validatetick
	equiptick = validatetick
	player = players:GetPlayerFromCharacter(tool.Parent)
	character = player.Character
	charhum = character:FindFirstChildOfClass("Humanoid")
	weldlimb(character.HumanoidRootPart, character.Torso, cfnew(), "HumanoidRootPartWeld")
	weldlimb(character.Torso, character.Head, cfnew(0,1.5,0), "HeadWeld")
	weldlimb(character.Head, character["Right Arm"], cfnew(1.43301296, -0.691987038, 0.466506958, 0.866025388, 0, 0.5, -0.249999985, -0.866025329, 0.433012664, 0.433012694, -0.5, -0.75), "RightArmWeld")
	weldlimb(character.Head, character["Left Arm"], cfnew(-1.5, -1.5, 0, 1, 0, 0, 0, 0.99999994, 0, 0, 0, 1), "LeftArmWeld")
	local grip = character["Right Arm"]:WaitForChild("RightGrip")
	grip.C0 = cfnew(0.00500011444, -1, -1.34000015, -1.74622983e-10, 1.00000036, -6.56216748e-11, 0.999999881, -1.74622955e-10, 8.9406953e-08, -8.94069672e-08, 6.56216748e-11, -1)
	pose("equip", 1, 0.25, backuptick)
	wait(0.25)
	pose("equip", 2, 0.25, backuptick)
	wait(0.2)
	if state == "equipping" then
		state = "idle"
	end
end)
tool.Unequipped:Connect(function()
	state = "unequipped"
	local limb1 = findthing("HeadWeld", character)
	local limb2 = findthing("RightArmWeld", character)
	local limb3 = findthing("LeftArmWeld", character)
	local limb4 = findthing("HumanoidRootPartWeld", character)
	if limb1 then
		limb1:Destroy()
	end
	if limb2 then
		limb2:Destroy()
	end
	if limb3 then
		limb3:Destroy()
	end
	if limb4 then
		limb4:Destroy()
	end
end)