-- Tweens



function Animate(w1,w2,w3,tw,Time,Delay)

SetWelds()

weld1C1 = w1
weld2C1 = w2
weld3C1 = w3
tweldC1 = tw

TweenService:Create(neck,TweenInfo.new(Time),{C0=OriginalC0*CFrame.Angles(Answer,0,NeckRotation)}):Play()

SEs.FireClient:FireServer(k,"AnimateFE",{w1,w2,w3,tw},Time,Answer,0,NeckRotation,chr,Tool.Hig.Value)

if script:IsDescendantOf(chr) then
TweenService:Create(weld1,TweenInfo.new(Time),
	{C1=w1*CFrame.new(0,Tool.Hig.Value,0)}):Play()

TweenService:Create(weld2,TweenInfo.new(Time),
	{C1=w2*CFrame.new(0,Tool.Hig.Value,0)}):Play()

TweenService:Create(weld3,TweenInfo.new(Time),
	{C1=w3*CFrame.new(0,Tool.Hig.Value,0)}):Play()
			
TweenService:Create(tweld,TweenInfo.new(Time),
    {C1=tw*CFrame.new(0,Tool.Hig.Value,0)}):Play()
end

if Delay then Time = Time + Delay end
wait(Time) 
end

chr.Humanoid.Died:connect(function()
game.Workspace.CurrentCamera.FieldOfView = 70
end)

Mouse.Move:connect(function() -- Thanks to Ultimatedar for this logic, heavily edited by me.
    local Mouse = Player:GetMouse()
	local Direction = Mouse.Hit.p
	local B = head.Position.Y-Direction.Y
	local Dist = (head.Position-Direction).magnitude
	Answer = math.asin(B/Dist)
	Gyro.cframe = Mouse.Hit
	if Stance ~= "Nothing" then
	Answer = 0
	else if Stance == "Nothing" then
		if Answer > math.rad(20) then
			Answer = math.rad(20)
		elseif Answer < math.rad(-10) then
			Answer = math.rad(-10)
	    else if torso.Parent.Humanoid.Sit then
						Answer = 0
				end
	end
	end
	end
	
if (Stance == "Nothing") then

SEs.FireClient:FireServer(k,"Aglin",chr,Answer,{Answer,0,NeckRotation},0.1,Turning)
if not Turning then	
TweenService:Create(neck,TweenInfo.new(0.1),{C0=OriginalC0*CFrame.Angles(Answer,0,NeckRotation)}):Play()
end

TweenService:Create(fakeneck,TweenInfo.new(0.1),{C0=OriginalC0*CFrame.Angles(0,0,0)}):Play()

TweenService:Create(tiltweld,TweenInfo.new(0.1),{C0=CFrame.new(0,0,0) * CFrame.Angles(Answer,0,0)}):Play()

if Gyro.Parent ~= tilt and Tool.Skrimish.Value then Gyro.Parent = tilt chr.Humanoid.AutoRotate = false
 
elseif Gyro.Parent == tilt and not Tool.Skrimish.Value then Gyro.Parent = script chr.Humanoid.AutoRotate = true
 end

else
	
if Gyro.Parent == tilt then Gyro.Parent = script chr.Humanoid.AutoRotate = true
 end	

SEs.FireClient:FireServer(k,"Aglin",chr,Answer,{Answer,0,NeckRotation},0.1,Turning,true)
if not Turning then	
TweenService:Create(neck,TweenInfo.new(0.1),{C0=OriginalC0*CFrame.Angles(Answer,0,NeckRotation)}):Play()
end

TweenService:Create(fakeneck,TweenInfo.new(0.1),{C0=OriginalC0*CFrame.Angles(0,0,0)}):Play()

TweenService:Create(tiltweld,TweenInfo.new(0.1),{C0=CFrame.new(0,0,0) * CFrame.Angles(0,0,0)}):Play()
	
end
	if tick() - Cooldown > LastCheck then
		local NextUnit = Mouse.UnitRay.Unit.Direction
		if math.abs(NextUnit.Y - LastUnit.Y) >= 0.01 then
			if NextUnit.Y > LastUnit.Y then
				AttackDirection = "U"
			else
				AttackDirection = "D"
			end
		else
			if CalcHorizontalAngle(LastUnit*Vector3.new(1,0,1), NextUnit*Vector3.new(1,0,1)) > 0 then
				AttackDirection = "R"
			else
				AttackDirection = "L"
			end
		end
		LastUnit = NextUnit
	end	
end)

weld1C1 = weld1.C1
weld2C1 = weld2.C1
weld3C1 = weld3.C1
tweldC1 = tweld.C1

wait(0.1)